summaryrefslogtreecommitdiffstats
path: root/hl/examples
diff options
context:
space:
mode:
authorAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
committerAllen Byrne <byrn@hdfgroup.org>2020-09-30 14:27:10 (GMT)
commitb2d661b508a7fc7a2592c13bc6bdc175551f075d (patch)
tree13baeb0d83a7c2a4c6299993c182b1227c2f6114 /hl/examples
parent29ab58b58dce556639ea3154e262895773a8a8df (diff)
downloadhdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.zip
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.gz
hdf5-b2d661b508a7fc7a2592c13bc6bdc175551f075d.tar.bz2
Clang-format of source files
Diffstat (limited to 'hl/examples')
-rw-r--r--hl/examples/ex_ds1.c176
-rw-r--r--hl/examples/ex_image1.c85
-rw-r--r--hl/examples/ex_image2.c274
-rw-r--r--hl/examples/ex_lite1.c27
-rw-r--r--hl/examples/ex_lite2.c50
-rw-r--r--hl/examples/ex_lite3.c70
-rw-r--r--hl/examples/ex_table_01.c189
-rw-r--r--hl/examples/ex_table_02.c180
-rw-r--r--hl/examples/ex_table_03.c187
-rw-r--r--hl/examples/ex_table_04.c246
-rw-r--r--hl/examples/ex_table_05.c242
-rw-r--r--hl/examples/ex_table_06.c123
-rw-r--r--hl/examples/ex_table_07.c155
-rw-r--r--hl/examples/ex_table_08.c205
-rw-r--r--hl/examples/ex_table_09.c210
-rw-r--r--hl/examples/ex_table_10.c196
-rw-r--r--hl/examples/ex_table_11.c164
-rw-r--r--hl/examples/ex_table_12.c148
-rw-r--r--hl/examples/pal_rgb.h7
-rw-r--r--hl/examples/ptExampleFL.c88
20 files changed, 1373 insertions, 1649 deletions
diff --git a/hl/examples/ex_ds1.c b/hl/examples/ex_ds1.c
index 1e0c592..af8b581 100644
--- a/hl/examples/ex_ds1.c
+++ b/hl/examples/ex_ds1.c
@@ -14,99 +14,93 @@
#include "hdf5.h"
#include "hdf5_hl.h"
-
-#define RANK 2
-#define DIM_DATA 12
-#define DIM1_SIZE 3
-#define DIM2_SIZE 4
-#define DIM0 0
-#define DIM1 1
-
-#define DSET_NAME "Mydata"
-#define DS_1_NAME "Yaxis"
-#define DS_2_NAME "Xaxis"
-
-int main(void)
+#define RANK 2
+#define DIM_DATA 12
+#define DIM1_SIZE 3
+#define DIM2_SIZE 4
+#define DIM0 0
+#define DIM1 1
+
+#define DSET_NAME "Mydata"
+#define DS_1_NAME "Yaxis"
+#define DS_2_NAME "Xaxis"
+
+int
+main(void)
{
- hid_t fid; /* file ID */
- hid_t did; /* dataset ID */
- hid_t dsid; /* DS dataset ID */
- int rank = RANK; /* rank of data dataset */
- int rankds = 1; /* rank of DS dataset */
- hsize_t dims[RANK] = {DIM1_SIZE,DIM2_SIZE}; /* size of data dataset */
- int buf[DIM_DATA] = {1,2,3,4,5,6,7,8,9,10,11,12}; /* data of data dataset */
- hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
- hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
- float s1_wbuf[DIM1_SIZE] = {10,20,30}; /* data of DS 1 dataset */
- int s2_wbuf[DIM2_SIZE] = {10,20,50,100}; /* data of DS 2 dataset */
-
-
- /* create a file using default properties */
- if ((fid=H5Fcreate("ex_ds1.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT))<0)
- goto out;
-
- /* make a dataset */
- if (H5LTmake_dataset_int(fid,DSET_NAME,rank,dims,buf)<0)
- goto out;
-
- /* make a DS dataset for the first dimension */
- if (H5LTmake_dataset_float(fid,DS_1_NAME,rankds,s1_dim,s1_wbuf)<0)
- goto out;
-
- /* make a DS dataset for the second dimension */
- if (H5LTmake_dataset_int(fid,DS_2_NAME,rankds,s2_dim,s2_wbuf)<0)
- goto out;
-
-
-/*-------------------------------------------------------------------------
- * attach the DS_1_NAME dimension scale to DSET_NAME at dimension 0
- *-------------------------------------------------------------------------
- */
-
- /* get the dataset id for DSET_NAME */
- if ((did = H5Dopen2(fid,DSET_NAME, H5P_DEFAULT))<0)
- goto out;
-
- /* get the DS dataset id */
- if ((dsid = H5Dopen2(fid,DS_1_NAME, H5P_DEFAULT))<0)
- goto out;
-
- /* attach the DS_1_NAME dimension scale to DSET_NAME at dimension index 0 */
- if (H5DSattach_scale(did,dsid,DIM0)<0)
- goto out;
-
- /* close DS id */
- if (H5Dclose(dsid)<0)
- goto out;
-
-/*-------------------------------------------------------------------------
- * attach the DS_2_NAME dimension scale to DSET_NAME
- *-------------------------------------------------------------------------
- */
-
- /* get the DS dataset id */
- if ((dsid = H5Dopen2(fid,DS_2_NAME, H5P_DEFAULT))<0)
- goto out;
-
- /* attach the DS_2_NAME dimension scale to DSET_NAME as the 2nd dimension (index 1) */
- if (H5DSattach_scale(did,dsid,DIM1)<0)
- goto out;
-
- /* close DS id */
- if (H5Dclose(dsid)<0)
- goto out;
-
- /* close file */
- H5Fclose(fid);
-
- return 0;
+ hid_t fid; /* file ID */
+ hid_t did; /* dataset ID */
+ hid_t dsid; /* DS dataset ID */
+ int rank = RANK; /* rank of data dataset */
+ int rankds = 1; /* rank of DS dataset */
+ hsize_t dims[RANK] = {DIM1_SIZE, DIM2_SIZE}; /* size of data dataset */
+ int buf[DIM_DATA] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12}; /* data of data dataset */
+ hsize_t s1_dim[1] = {DIM1_SIZE}; /* size of DS 1 dataset */
+ hsize_t s2_dim[1] = {DIM2_SIZE}; /* size of DS 2 dataset */
+ float s1_wbuf[DIM1_SIZE] = {10, 20, 30}; /* data of DS 1 dataset */
+ int s2_wbuf[DIM2_SIZE] = {10, 20, 50, 100}; /* data of DS 2 dataset */
+
+ /* create a file using default properties */
+ if ((fid = H5Fcreate("ex_ds1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* make a dataset */
+ if (H5LTmake_dataset_int(fid, DSET_NAME, rank, dims, buf) < 0)
+ goto out;
+
+ /* make a DS dataset for the first dimension */
+ if (H5LTmake_dataset_float(fid, DS_1_NAME, rankds, s1_dim, s1_wbuf) < 0)
+ goto out;
+
+ /* make a DS dataset for the second dimension */
+ if (H5LTmake_dataset_int(fid, DS_2_NAME, rankds, s2_dim, s2_wbuf) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * attach the DS_1_NAME dimension scale to DSET_NAME at dimension 0
+ *-------------------------------------------------------------------------
+ */
+
+ /* get the dataset id for DSET_NAME */
+ if ((did = H5Dopen2(fid, DSET_NAME, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* get the DS dataset id */
+ if ((dsid = H5Dopen2(fid, DS_1_NAME, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* attach the DS_1_NAME dimension scale to DSET_NAME at dimension index 0 */
+ if (H5DSattach_scale(did, dsid, DIM0) < 0)
+ goto out;
+
+ /* close DS id */
+ if (H5Dclose(dsid) < 0)
+ goto out;
+
+ /*-------------------------------------------------------------------------
+ * attach the DS_2_NAME dimension scale to DSET_NAME
+ *-------------------------------------------------------------------------
+ */
+
+ /* get the DS dataset id */
+ if ((dsid = H5Dopen2(fid, DS_2_NAME, H5P_DEFAULT)) < 0)
+ goto out;
+
+ /* attach the DS_2_NAME dimension scale to DSET_NAME as the 2nd dimension (index 1) */
+ if (H5DSattach_scale(did, dsid, DIM1) < 0)
+ goto out;
+
+ /* close DS id */
+ if (H5Dclose(dsid) < 0)
+ goto out;
+
+ /* close file */
+ H5Fclose(fid);
+
+ return 0;
out:
- printf("Error on return function...Exiting\n");
- return 1;
-
+ printf("Error on return function...Exiting\n");
+ return 1;
}
-
-
-
diff --git a/hl/examples/ex_image1.c b/hl/examples/ex_image1.c
index 56a175d..ef9410b 100644
--- a/hl/examples/ex_image1.c
+++ b/hl/examples/ex_image1.c
@@ -14,56 +14,55 @@
#include "hdf5.h"
#include "hdf5_hl.h"
-#define WIDTH 400
-#define HEIGHT 200
-#define PAL_ENTRIES 9
-unsigned char buf [ WIDTH*HEIGHT ];
+#define WIDTH 400
+#define HEIGHT 200
+#define PAL_ENTRIES 9
+unsigned char buf[WIDTH * HEIGHT];
-int main( void )
+int
+main(void)
{
- hid_t file_id;
- hsize_t pal_dims[] = {PAL_ENTRIES,3};
- size_t i, j;
- int n, space;
- unsigned char pal[PAL_ENTRIES*3] = { /* create a palette with 9 colors */
- 0,0,168, /* dark blue */
- 0,0,252, /* blue */
- 0,168,252, /* ocean blue */
- 84,252,252, /* light blue */
- 168,252,168, /* light green */
- 0,252,168, /* green */
- 252,252,84, /* yellow */
- 252,168,0, /* orange */
- 252,0,0}; /* red */
+ hid_t file_id;
+ hsize_t pal_dims[] = {PAL_ENTRIES, 3};
+ size_t i, j;
+ int n, space;
+ unsigned char pal[PAL_ENTRIES * 3] = { /* create a palette with 9 colors */
+ 0, 0, 168, /* dark blue */
+ 0, 0, 252, /* blue */
+ 0, 168, 252, /* ocean blue */
+ 84, 252, 252, /* light blue */
+ 168, 252, 168, /* light green */
+ 0, 252, 168, /* green */
+ 252, 252, 84, /* yellow */
+ 252, 168, 0, /* orange */
+ 252, 0, 0}; /* red */
- /* create an image of 9 values divided evenly by the array */
- space = WIDTH*HEIGHT / PAL_ENTRIES;
- for (i=0, j=0, n=0; i < WIDTH*HEIGHT; i++, j++ )
- {
- buf[i] = n;
- if ( j > space )
- {
- n++;
- j=0;
- }
- if (n>PAL_ENTRIES-1) n=0;
- }
+ /* create an image of 9 values divided evenly by the array */
+ space = WIDTH * HEIGHT / PAL_ENTRIES;
+ for (i = 0, j = 0, n = 0; i < WIDTH * HEIGHT; i++, j++) {
+ buf[i] = n;
+ if (j > space) {
+ n++;
+ j = 0;
+ }
+ if (n > PAL_ENTRIES - 1)
+ n = 0;
+ }
- /* create a new HDF5 file using default properties. */
- file_id = H5Fcreate( "ex_image1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
+ /* create a new HDF5 file using default properties. */
+ file_id = H5Fcreate("ex_image1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* make the image */
- H5IMmake_image_8bit( file_id, "image1", (hsize_t)WIDTH, (hsize_t)HEIGHT, buf );
+ /* make the image */
+ H5IMmake_image_8bit(file_id, "image1", (hsize_t)WIDTH, (hsize_t)HEIGHT, buf);
- /* make a palette */
- H5IMmake_palette( file_id, "pallete", pal_dims, pal );
+ /* make a palette */
+ H5IMmake_palette(file_id, "pallete", pal_dims, pal);
- /* attach the palette to the image */
- H5IMlink_palette( file_id, "image1", "pallete" );
+ /* attach the palette to the image */
+ H5IMlink_palette(file_id, "image1", "pallete");
- /* close the file. */
- H5Fclose( file_id );
-
- return 0;
+ /* close the file. */
+ H5Fclose(file_id);
+ return 0;
}
diff --git a/hl/examples/ex_image2.c b/hl/examples/ex_image2.c
index 5abf723..2a38430 100644
--- a/hl/examples/ex_image2.c
+++ b/hl/examples/ex_image2.c
@@ -16,90 +16,89 @@
#include <stdlib.h>
#include <string.h>
-#define DATA_FILE1 "image8.txt"
-#define DATA_FILE2 "image24pixel.txt"
-#define IMAGE1_NAME "image8bit"
-#define IMAGE2_NAME "image24bitpixel"
-#define PAL_NAME "palette"
-#define PAL_ENTRIES 256
-
-static int read_data(const char* file_name, hsize_t *width, hsize_t *height );
-unsigned char *gbuf = NULL; /* global buffer for image data */
-
-int main( void )
+#define DATA_FILE1 "image8.txt"
+#define DATA_FILE2 "image24pixel.txt"
+#define IMAGE1_NAME "image8bit"
+#define IMAGE2_NAME "image24bitpixel"
+#define PAL_NAME "palette"
+#define PAL_ENTRIES 256
+
+static int read_data(const char *file_name, hsize_t *width, hsize_t *height);
+unsigned char *gbuf = NULL; /* global buffer for image data */
+
+int
+main(void)
{
- hid_t file_id; /* HDF5 file identifier */
- hsize_t width; /* width of image */
- hsize_t height; /* height of image */
- unsigned char pal[ PAL_ENTRIES * 3 ]; /* palette array */
- hsize_t pal_dims[2] = {PAL_ENTRIES,3}; /* palette dimensions */
- herr_t i, n;
-
- /* create a new HDF5 file using default properties. */
- file_id = H5Fcreate( "ex_image2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* read first data file */
- if (read_data(DATA_FILE1,&width,&height)<0)
- goto out;
-
- /* make the image */
- H5IMmake_image_8bit( file_id, IMAGE1_NAME, width, height, gbuf );
- if (gbuf) {
- free(gbuf);
- gbuf = NULL;
- }
-
-/*-------------------------------------------------------------------------
- * define a palette, blue to red tones
- *-------------------------------------------------------------------------
- */
- for ( i=0, n=0; i<PAL_ENTRIES*3; i+=3, n++)
- {
- pal[i] =n; /* red */
- pal[i+1]=0; /* green */
- pal[i+2]=255-n; /* blue */
- }
-
- /* make a palette */
- H5IMmake_palette( file_id, PAL_NAME, pal_dims, pal );
-
- /* attach the palette to the image */
- H5IMlink_palette( file_id, IMAGE1_NAME, PAL_NAME );
-
-/*-------------------------------------------------------------------------
- * True color image example with pixel interlace
- *-------------------------------------------------------------------------
- */
-
- /* read second data file */
- if (read_data(DATA_FILE2,&width,&height)<0)
- goto out;
-
- /* make dataset */
- H5IMmake_image_24bit( file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf );
-
- /* close the file. */
- H5Fclose( file_id );
-
- if(gbuf) {
- free(gbuf);
- gbuf = NULL;
- }
-
- return 0;
+ hid_t file_id; /* HDF5 file identifier */
+ hsize_t width; /* width of image */
+ hsize_t height; /* height of image */
+ unsigned char pal[PAL_ENTRIES * 3]; /* palette array */
+ hsize_t pal_dims[2] = {PAL_ENTRIES, 3}; /* palette dimensions */
+ herr_t i, n;
+
+ /* create a new HDF5 file using default properties. */
+ file_id = H5Fcreate("ex_image2.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* read first data file */
+ if (read_data(DATA_FILE1, &width, &height) < 0)
+ goto out;
+
+ /* make the image */
+ H5IMmake_image_8bit(file_id, IMAGE1_NAME, width, height, gbuf);
+ if (gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
+
+ /*-------------------------------------------------------------------------
+ * define a palette, blue to red tones
+ *-------------------------------------------------------------------------
+ */
+ for (i = 0, n = 0; i < PAL_ENTRIES * 3; i += 3, n++) {
+ pal[i] = n; /* red */
+ pal[i + 1] = 0; /* green */
+ pal[i + 2] = 255 - n; /* blue */
+ }
+
+ /* make a palette */
+ H5IMmake_palette(file_id, PAL_NAME, pal_dims, pal);
+
+ /* attach the palette to the image */
+ H5IMlink_palette(file_id, IMAGE1_NAME, PAL_NAME);
+
+ /*-------------------------------------------------------------------------
+ * True color image example with pixel interlace
+ *-------------------------------------------------------------------------
+ */
+
+ /* read second data file */
+ if (read_data(DATA_FILE2, &width, &height) < 0)
+ goto out;
+
+ /* make dataset */
+ H5IMmake_image_24bit(file_id, IMAGE2_NAME, width, height, "INTERLACE_PIXEL", gbuf);
+
+ /* close the file. */
+ H5Fclose(file_id);
+
+ if (gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
+
+ return 0;
out:
- printf("Error on return function...Exiting\n");
+ printf("Error on return function...Exiting\n");
- if(gbuf) {
- free(gbuf);
- gbuf = NULL;
- }
+ if (gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
- return 1;
+ return 1;
}
-
/*-------------------------------------------------------------------------
* read_data
* utility function to read ASCII image data
@@ -117,68 +116,63 @@ out:
*-------------------------------------------------------------------------
*/
-static int read_data( const char* fname, /*IN*/
- hsize_t *width, /*OUT*/
- hsize_t *height /*OUT*/ )
+static int
+read_data(const char *fname, /*IN*/
+ hsize_t * width, /*OUT*/
+ hsize_t * height /*OUT*/)
{
- int i, n;
- int color_planes;
- char str[20];
- FILE *f;
- int w, h;
- char *srcdir = getenv("srcdir"); /* the source directory */
- char data_file[512]=""; /* buffer to hold name of existing data file */
-
-/*-------------------------------------------------------------------------
- * compose the name of the file to open, using "srcdir", if appropriate
- *-------------------------------------------------------------------------
- */
- strcpy(data_file, "");
- if (srcdir)
- {
- strcpy(data_file, srcdir);
- strcat(data_file, "/");
- }
- strcat(data_file,fname);
-
-/*-------------------------------------------------------------------------
- * read
- *-------------------------------------------------------------------------
- */
-
- f = fopen(data_file, "r");
- if ( f == NULL )
- {
- printf( "Could not open file %s. Try set $srcdir \n", data_file );
- return -1;
- }
-
- fscanf( f, "%s", str );
- fscanf( f, "%d", &color_planes );
- fscanf( f, "%s", str );
- fscanf( f, "%d", &h);
- fscanf( f, "%s", str );
- fscanf( f, "%d", &w);
-
- *width = (hsize_t)w;
- *height = (hsize_t)h;
-
- if ( gbuf )
- {
- free( gbuf );
- gbuf=NULL;
- }
-
- gbuf = (unsigned char*) malloc (w * h * color_planes * sizeof( unsigned char ));
-
- for (i = 0; i < h * w * color_planes ; i++)
- {
- fscanf( f, "%d",&n );
- gbuf[i] = (unsigned char)n;
- }
- fclose(f);
-
- return 1;
-
+ int i, n;
+ int color_planes;
+ char str[20];
+ FILE *f;
+ int w, h;
+ char *srcdir = getenv("srcdir"); /* the source directory */
+ char data_file[512] = ""; /* buffer to hold name of existing data file */
+
+ /*-------------------------------------------------------------------------
+ * compose the name of the file to open, using "srcdir", if appropriate
+ *-------------------------------------------------------------------------
+ */
+ strcpy(data_file, "");
+ if (srcdir) {
+ strcpy(data_file, srcdir);
+ strcat(data_file, "/");
+ }
+ strcat(data_file, fname);
+
+ /*-------------------------------------------------------------------------
+ * read
+ *-------------------------------------------------------------------------
+ */
+
+ f = fopen(data_file, "r");
+ if (f == NULL) {
+ printf("Could not open file %s. Try set $srcdir \n", data_file);
+ return -1;
+ }
+
+ fscanf(f, "%s", str);
+ fscanf(f, "%d", &color_planes);
+ fscanf(f, "%s", str);
+ fscanf(f, "%d", &h);
+ fscanf(f, "%s", str);
+ fscanf(f, "%d", &w);
+
+ *width = (hsize_t)w;
+ *height = (hsize_t)h;
+
+ if (gbuf) {
+ free(gbuf);
+ gbuf = NULL;
+ }
+
+ gbuf = (unsigned char *)malloc(w * h * color_planes * sizeof(unsigned char));
+
+ for (i = 0; i < h * w * color_planes; i++) {
+ fscanf(f, "%d", &n);
+ gbuf[i] = (unsigned char)n;
+ }
+ fclose(f);
+
+ return 1;
}
-
diff --git a/hl/examples/ex_lite1.c b/hl/examples/ex_lite1.c
index 89f60dc..3056480 100644
--- a/hl/examples/ex_lite1.c
+++ b/hl/examples/ex_lite1.c
@@ -11,29 +11,26 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "hdf5.h"
#include "hdf5_hl.h"
#define RANK 2
-
-int main( void )
+int
+main(void)
{
- hid_t file_id;
- hsize_t dims[RANK]={2,3};
- int data[6]={1,2,3,4,5,6};
+ hid_t file_id;
+ hsize_t dims[RANK] = {2, 3};
+ int data[6] = {1, 2, 3, 4, 5, 6};
- /* create a HDF5 file */
- file_id = H5Fcreate ("ex_lite1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* create a HDF5 file */
+ file_id = H5Fcreate("ex_lite1.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* create and write an integer type dataset named "dset" */
- H5LTmake_dataset(file_id,"/dset",RANK,dims,H5T_NATIVE_INT,data);
+ /* create and write an integer type dataset named "dset" */
+ H5LTmake_dataset(file_id, "/dset", RANK, dims, H5T_NATIVE_INT, data);
- /* close file */
- H5Fclose (file_id);
+ /* close file */
+ H5Fclose(file_id);
- return 0;
+ return 0;
}
-
-
diff --git a/hl/examples/ex_lite2.c b/hl/examples/ex_lite2.c
index 261fc73..4441844 100644
--- a/hl/examples/ex_lite2.c
+++ b/hl/examples/ex_lite2.c
@@ -14,38 +14,34 @@
#include "hdf5.h"
#include "hdf5_hl.h"
-int main( void )
+int
+main(void)
{
- hid_t file_id;
- int data[6];
- hsize_t dims[2];
- size_t i, j, nrow, n_values;
+ hid_t file_id;
+ int data[6];
+ hsize_t dims[2];
+ size_t i, j, nrow, n_values;
- /* open file from ex_lite1.c */
- file_id = H5Fopen ("ex_lite1.h5", H5F_ACC_RDONLY, H5P_DEFAULT);
+ /* open file from ex_lite1.c */
+ file_id = H5Fopen("ex_lite1.h5", H5F_ACC_RDONLY, H5P_DEFAULT);
- /* read dataset */
- H5LTread_dataset_int(file_id,"/dset",data);
+ /* read dataset */
+ H5LTread_dataset_int(file_id, "/dset", data);
- /* get the dimensions of the dataset */
- H5LTget_dataset_info(file_id,"/dset",dims,NULL,NULL);
+ /* get the dimensions of the dataset */
+ H5LTget_dataset_info(file_id, "/dset", dims, NULL, NULL);
- /* print it by rows */
- n_values = (size_t)(dims[0] * dims[1]);
- nrow = (size_t)dims[1];
- for (i=0; i<n_values/nrow; i++ )
- {
- for (j=0; j<nrow; j++)
- printf (" %d", data[i*nrow + j]);
- printf ("\n");
- }
-
- /* close file */
- H5Fclose (file_id);
-
- return 0;
+ /* print it by rows */
+ n_values = (size_t)(dims[0] * dims[1]);
+ nrow = (size_t)dims[1];
+ for (i = 0; i < n_values / nrow; i++) {
+ for (j = 0; j < nrow; j++)
+ printf(" %d", data[i * nrow + j]);
+ printf("\n");
+ }
+ /* close file */
+ H5Fclose(file_id);
+ return 0;
}
-
-
diff --git a/hl/examples/ex_lite3.c b/hl/examples/ex_lite3.c
index 420cbcb..f80582e 100644
--- a/hl/examples/ex_lite3.c
+++ b/hl/examples/ex_lite3.c
@@ -17,51 +17,51 @@
#define ATTR_SIZE 5
-int main( void )
+int
+main(void)
{
- hid_t file_id;
- hid_t dset_id;
- hid_t space_id;
- hsize_t dims[1] = { ATTR_SIZE };
- int data[ATTR_SIZE] = {1,2,3,4,5};
- int i;
+ hid_t file_id;
+ hid_t dset_id;
+ hid_t space_id;
+ hsize_t dims[1] = {ATTR_SIZE};
+ int data[ATTR_SIZE] = {1, 2, 3, 4, 5};
+ int i;
- /* create a file */
- file_id = H5Fcreate("ex_lite3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+ /* create a file */
+ file_id = H5Fcreate("ex_lite3.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
- /* create a data space */
- space_id = H5Screate_simple(1, dims, NULL);
+ /* create a data space */
+ space_id = H5Screate_simple(1, dims, NULL);
- /* create a dataset named "dset" */
- dset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ /* create a dataset named "dset" */
+ dset_id = H5Dcreate2(file_id, "dset", H5T_NATIVE_INT, space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
- /* close */
- H5Dclose(dset_id);
- H5Sclose(space_id);
+ /* close */
+ H5Dclose(dset_id);
+ H5Sclose(space_id);
-/*-------------------------------------------------------------------------
- * example of H5LTset_attribute_int
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * example of H5LTset_attribute_int
+ *-------------------------------------------------------------------------
+ */
- /* create and write the attribute "attr1" on the dataset "dset" */
- H5LTset_attribute_int(file_id, "dset", "attr1", data, ATTR_SIZE);
+ /* create and write the attribute "attr1" on the dataset "dset" */
+ H5LTset_attribute_int(file_id, "dset", "attr1", data, ATTR_SIZE);
-/*-------------------------------------------------------------------------
- * example of H5LTget_attribute_int
- *-------------------------------------------------------------------------
- */
+ /*-------------------------------------------------------------------------
+ * example of H5LTget_attribute_int
+ *-------------------------------------------------------------------------
+ */
- /* get the attribute "attr1" from the dataset "dset" */
- H5LTget_attribute_int(file_id, "dset", "attr1", data);
+ /* get the attribute "attr1" from the dataset "dset" */
+ H5LTget_attribute_int(file_id, "dset", "attr1", data);
- for(i = 0; i < ATTR_SIZE; i++ )
- printf(" %d", data[i]);
- printf("\n");
+ for (i = 0; i < ATTR_SIZE; i++)
+ printf(" %d", data[i]);
+ printf("\n");
- /* close file */
- H5Fclose(file_id);
+ /* close file */
+ H5Fclose(file_id);
- return 0;
+ return 0;
}
-
diff --git a/hl/examples/ex_table_01.c b/hl/examples/ex_table_01.c
index f1d0266..f3f1b0d 100644
--- a/hl/examples/ex_table_01.c
+++ b/hl/examples/ex_table_01.c
@@ -24,112 +24,91 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
#define TABLE_NAME "table"
-
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- Particle dst_buf[NRECORDS];
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
-
- size_t dst_sizes[NFIELDS] = { sizeof( dst_buf[0].name),
- sizeof( dst_buf[0].lati),
- sizeof( dst_buf[0].longi),
- sizeof( dst_buf[0].pressure),
- sizeof( dst_buf[0].temperature)};
-
-
- /* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int *fill_data = NULL;
- int compress = 0;
- int i;
-
- /* Initialize field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_01.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
-/*-------------------------------------------------------------------------
- * H5TBmake_table
- *-------------------------------------------------------------------------
- */
-
- H5TBmake_table( "Table Title", file_id, TABLE_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
-/*-------------------------------------------------------------------------
- * H5TBread_table
- *-------------------------------------------------------------------------
- */
-
- H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* print it by rows */
- for (i=0; i<NRECORDS; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
-/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ Particle dst_buf[NRECORDS];
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+
+ size_t dst_sizes[NFIELDS] = {sizeof(dst_buf[0].name), sizeof(dst_buf[0].lati), sizeof(dst_buf[0].longi),
+ sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int * fill_data = NULL;
+ int compress = 0;
+ int i;
+
+ /* Initialize field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_01.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /*-------------------------------------------------------------------------
+ * H5TBmake_table
+ *-------------------------------------------------------------------------
+ */
+
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /*-------------------------------------------------------------------------
+ * H5TBread_table
+ *-------------------------------------------------------------------------
+ */
+
+ H5TBread_table(file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* print it by rows */
+ for (i = 0; i < NRECORDS; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /*-------------------------------------------------------------------------
+ * end
+ *-------------------------------------------------------------------------
+ */
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_02.c b/hl/examples/ex_table_02.c
index 923f810..2c2f56b 100644
--- a/hl/examples/ex_table_02.c
+++ b/hl/examples/ex_table_02.c
@@ -23,107 +23,85 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define NRECORDS_ADD (hsize_t) 2
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define NRECORDS_ADD (hsize_t)2
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- Particle dst_buf[NRECORDS+NRECORDS_ADD];
-
-/* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
-
- size_t dst_sizes[NFIELDS] = { sizeof( p_data[0].name),
- sizeof( p_data[0].lati),
- sizeof( p_data[0].longi),
- sizeof( p_data[0].pressure),
- sizeof( p_data[0].temperature)};
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int *fill_data = NULL;
- int compress = 0;
- int i;
-
- /* Append particles */
- Particle particle_in[ NRECORDS_ADD ] =
- {{ "eight",80,80, 8.0f, 80.0},
- {"nine",90,90, 9.0f, 90.0} };
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_02.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* make a table */
- H5TBmake_table( "Table Title",file_id,TABLE_NAME,NFIELDS,NRECORDS,
- dst_size, field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* append two records */
- H5TBappend_records(file_id, TABLE_NAME,NRECORDS_ADD, dst_size, dst_offset, dst_sizes,
- &particle_in );
-
- /* read the table */
- H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* print it by rows */
- for (i=0; i<NRECORDS+NRECORDS_ADD; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ Particle dst_buf[NRECORDS + NRECORDS_ADD];
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+
+ size_t dst_sizes[NFIELDS] = {sizeof(p_data[0].name), sizeof(p_data[0].lati), sizeof(p_data[0].longi),
+ sizeof(p_data[0].pressure), sizeof(p_data[0].temperature)};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int * fill_data = NULL;
+ int compress = 0;
+ int i;
+
+ /* Append particles */
+ Particle particle_in[NRECORDS_ADD] = {{"eight", 80, 80, 8.0f, 80.0}, {"nine", 90, 90, 9.0f, 90.0}};
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_02.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* make a table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* append two records */
+ H5TBappend_records(file_id, TABLE_NAME, NRECORDS_ADD, dst_size, dst_offset, dst_sizes, &particle_in);
+
+ /* read the table */
+ H5TBread_table(file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* print it by rows */
+ for (i = 0; i < NRECORDS + NRECORDS_ADD; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_03.c b/hl/examples/ex_table_03.c
index 76a9eae..8787275 100644
--- a/hl/examples/ex_table_03.c
+++ b/hl/examples/ex_table_03.c
@@ -11,7 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "hdf5.h"
#include "hdf5_hl.h"
#include <stdlib.h>
@@ -24,113 +23,85 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define NRECORDS_WRITE (hsize_t) 2
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define NRECORDS_WRITE (hsize_t)2
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- Particle dst_buf[NRECORDS];
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
-
- Particle p = {"zero",0,0, 0.0f, 0.0};
- size_t dst_sizes[NFIELDS] = { sizeof( p.name),
- sizeof( p.lati),
- sizeof( p.longi),
- sizeof( p.pressure),
- sizeof( p.temperature)};
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- /* Fill value particle */
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- hsize_t start; /* Record to start reading/writing */
- hsize_t nrecords; /* Number of records to read/write */
- int i;
-
- /* Define 2 new particles to write */
- Particle particle_in[NRECORDS_WRITE] =
- { {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0} };
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
-/* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_03.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make the table */
- H5TBmake_table( "Table Title",
- file_id,
- TABLE_NAME,
- NFIELDS,
- NRECORDS,
- dst_size,
- field_names,
- dst_offset,
- field_type,
- chunk_size,
- fill_data,
- 0, /* no compression */
- NULL ); /* no data written */
-
-
- /* Overwrite 2 records starting at record 0 */
- start = 0;
- nrecords = NRECORDS_WRITE;
- H5TBwrite_records( file_id, TABLE_NAME, start, nrecords, dst_size, dst_offset,
- dst_sizes, particle_in);
-
- /* read the table */
- H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* print it by rows */
- for (i=0; i<NRECORDS; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ Particle dst_buf[NRECORDS];
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+
+ Particle p = {"zero", 0, 0, 0.0f, 0.0};
+ size_t dst_sizes[NFIELDS] = {sizeof(p.name), sizeof(p.lati), sizeof(p.longi), sizeof(p.pressure),
+ sizeof(p.temperature)};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ /* Fill value particle */
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ hsize_t start; /* Record to start reading/writing */
+ hsize_t nrecords; /* Number of records to read/write */
+ int i;
+
+ /* Define 2 new particles to write */
+ Particle particle_in[NRECORDS_WRITE] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0}};
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_03.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make the table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, 0, /* no compression */
+ NULL); /* no data written */
+
+ /* Overwrite 2 records starting at record 0 */
+ start = 0;
+ nrecords = NRECORDS_WRITE;
+ H5TBwrite_records(file_id, TABLE_NAME, start, nrecords, dst_size, dst_offset, dst_sizes, particle_in);
+
+ /* read the table */
+ H5TBread_table(file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* print it by rows */
+ for (i = 0; i < NRECORDS; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_04.c b/hl/examples/ex_table_04.c
index 203114c..9cb9137 100644
--- a/hl/examples/ex_table_04.c
+++ b/hl/examples/ex_table_04.c
@@ -23,141 +23,117 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define NRECORDS_ADD (hsize_t) 3
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define NRECORDS_ADD (hsize_t)3
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- /* Define a subset of Particle, with latitude and longitude fields */
- typedef struct Position
- {
- int lati;
- int longi;
- } Position;
-
- /* Define a subset of Particle, with name and pressure fields */
- typedef struct NamePressure
- {
- char name[16];
- float pressure;
- } NamePressure;
-
- Particle dst_buf[NRECORDS];
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
- size_t dst_sizes[NFIELDS] = { sizeof( dst_buf[0].name),
- sizeof( dst_buf[0].lati),
- sizeof( dst_buf[0].longi),
- sizeof( dst_buf[0].pressure),
- sizeof( dst_buf[0].temperature)};
- size_t field_offset_pos[2] = { HOFFSET( Position, lati ),
- HOFFSET( Position, longi )};
- const char *field_names[NFIELDS] = /* Define field information */
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} }; /* Fill value particle */
- hsize_t start; /* Record to start reading/writing */
- hsize_t nrecords; /* Number of records to read/write */
- int compress = 0;
- int i;
- Particle *p_data = NULL; /* Initially no data */
- float pressure_in [NRECORDS_ADD] = /* Define new values for the field "Pressure" */
- { 0.0f,1.0f,2.0f};
- Position position_in[NRECORDS_ADD] = {/* Define new values for "Latitude,Longitude" */
- {0,0},
- {10,10},
- {20,20}};
- NamePressure namepre_in[NRECORDS_ADD] =/* Define new values for "Name,Pressure" */
- { {"zero",0.0f},
- {"one", 1.0f},
- {"two", 2.0f},
- };
- size_t field_sizes_pos[2]=
- {
- sizeof(position_in[0].longi),
- sizeof(position_in[0].lati)
- };
- size_t field_sizes_pre[1]=
- {
- sizeof(namepre_in[0].pressure)
- };
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_04.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make the table */
- H5TBmake_table( "Table Title",file_id,TABLE_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Write the pressure field starting at record 2 */
- start = 2;
- nrecords = NRECORDS_ADD;
- H5TBwrite_fields_name( file_id, TABLE_NAME, "Pressure", start, nrecords,
- sizeof( float ), 0, field_sizes_pre, pressure_in );
-
- /* Write the new longitude and latitude information starting at record 2 */
- start = 2;
- nrecords = NRECORDS_ADD;
- H5TBwrite_fields_name( file_id, TABLE_NAME, "Latitude,Longitude", start, nrecords,
- sizeof( Position ), field_offset_pos, field_sizes_pos, position_in );
-
- /* read the table */
- H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* print it by rows */
- for (i=0; i<NRECORDS; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
-/*-------------------------------------------------------------------------
- * end
- *-------------------------------------------------------------------------
- */
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ /* Define a subset of Particle, with latitude and longitude fields */
+ typedef struct Position {
+ int lati;
+ int longi;
+ } Position;
+
+ /* Define a subset of Particle, with name and pressure fields */
+ typedef struct NamePressure {
+ char name[16];
+ float pressure;
+ } NamePressure;
+
+ Particle dst_buf[NRECORDS];
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+ size_t dst_sizes[NFIELDS] = {sizeof(dst_buf[0].name), sizeof(dst_buf[0].lati), sizeof(dst_buf[0].longi),
+ sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
+ size_t field_offset_pos[2] = {HOFFSET(Position, lati), HOFFSET(Position, longi)};
+ const char *field_names[NFIELDS] = /* Define field information */
+ {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ hsize_t start; /* Record to start reading/writing */
+ hsize_t nrecords; /* Number of records to read/write */
+ int compress = 0;
+ int i;
+ Particle *p_data = NULL; /* Initially no data */
+ float pressure_in[NRECORDS_ADD] = /* Define new values for the field "Pressure" */
+ {0.0f, 1.0f, 2.0f};
+ Position position_in[NRECORDS_ADD] = {/* Define new values for "Latitude,Longitude" */
+ {0, 0},
+ {10, 10},
+ {20, 20}};
+ NamePressure namepre_in[NRECORDS_ADD] = /* Define new values for "Name,Pressure" */
+ {
+ {"zero", 0.0f},
+ {"one", 1.0f},
+ {"two", 2.0f},
+ };
+ size_t field_sizes_pos[2] = {sizeof(position_in[0].longi), sizeof(position_in[0].lati)};
+ size_t field_sizes_pre[1] = {sizeof(namepre_in[0].pressure)};
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_04.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make the table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Write the pressure field starting at record 2 */
+ start = 2;
+ nrecords = NRECORDS_ADD;
+ H5TBwrite_fields_name(file_id, TABLE_NAME, "Pressure", start, nrecords, sizeof(float), 0, field_sizes_pre,
+ pressure_in);
+
+ /* Write the new longitude and latitude information starting at record 2 */
+ start = 2;
+ nrecords = NRECORDS_ADD;
+ H5TBwrite_fields_name(file_id, TABLE_NAME, "Latitude,Longitude", start, nrecords, sizeof(Position),
+ field_offset_pos, field_sizes_pos, position_in);
+
+ /* read the table */
+ H5TBread_table(file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* print it by rows */
+ for (i = 0; i < NRECORDS; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /*-------------------------------------------------------------------------
+ * end
+ *-------------------------------------------------------------------------
+ */
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_05.c b/hl/examples/ex_table_05.c
index b43d635..ab1b77f 100644
--- a/hl/examples/ex_table_05.c
+++ b/hl/examples/ex_table_05.c
@@ -11,7 +11,6 @@
* help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
-
#include "hdf5.h"
#include "hdf5_hl.h"
#include <stdlib.h>
@@ -24,142 +23,111 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define NRECORDS_ADD (hsize_t) 3
-#define TABLE_NAME "table"
-
-
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define NRECORDS_ADD (hsize_t)3
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- /* Define a subset of Particle, with latitude and longitude fields */
- typedef struct Position
- {
- int lati;
- int longi;
- } Position;
-
- /* Calculate the type_size and the offsets of our struct members */
- Particle dst_buf[NRECORDS];
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
- size_t dst_sizes[NFIELDS] = { sizeof( dst_buf[0].name),
- sizeof( dst_buf[0].lati),
- sizeof( dst_buf[0].longi),
- sizeof( dst_buf[0].pressure),
- sizeof( dst_buf[0].temperature)};
-
- size_t field_offset_pos[2] = { HOFFSET( Position, lati ),
- HOFFSET( Position, longi )};
-
- /* Initially no data */
- Particle *p_data = NULL;
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} }; /* Fill value particle */
- int compress = 0;
- hsize_t nfields;
- hsize_t start; /* Record to start reading/writing */
- hsize_t nrecords; /* Number of records to read/write */
- int i;
-
- /* Define new values for the field "Pressure" */
- float pressure_in [NRECORDS_ADD] =
- { 0.0f,1.0f,2.0f};
- int field_index_pre[1] = { 3 };
- int field_index_pos[2] = { 1,2 };
-
- /* Define new values for the fields "Latitude,Longitude" */
- Position position_in[NRECORDS_ADD] = { {0,0},
- {10,10},
- {20,20} };
-
- size_t field_sizes_pos[2]=
- {
- sizeof(position_in[0].longi),
- sizeof(position_in[0].lati)
- };
-
- size_t field_sizes_pre[1]=
- {
- sizeof(float)
- };
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_05.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make the table */
- H5TBmake_table( "Table Title", file_id, TABLE_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Write the pressure field starting at record 2 */
- nfields = 1;
- start = 2;
- nrecords = NRECORDS_ADD;
- H5TBwrite_fields_index( file_id, TABLE_NAME, nfields, field_index_pre, start, nrecords,
- sizeof( float ), 0, field_sizes_pre, pressure_in );
-
-
- /* Write the new longitude and latitude information starting at record 2 */
- nfields = 2;
- start = 2;
- nrecords = NRECORDS_ADD;
- H5TBwrite_fields_index( file_id, TABLE_NAME, nfields, field_index_pos, start, nrecords,
- sizeof( Position ), field_offset_pos, field_sizes_pos, position_in );
-
-
- /* read the table */
- H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* print it by rows */
- for (i=0; i<NRECORDS; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ /* Define a subset of Particle, with latitude and longitude fields */
+ typedef struct Position {
+ int lati;
+ int longi;
+ } Position;
+
+ /* Calculate the type_size and the offsets of our struct members */
+ Particle dst_buf[NRECORDS];
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+ size_t dst_sizes[NFIELDS] = {sizeof(dst_buf[0].name), sizeof(dst_buf[0].lati), sizeof(dst_buf[0].longi),
+ sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
+
+ size_t field_offset_pos[2] = {HOFFSET(Position, lati), HOFFSET(Position, longi)};
+
+ /* Initially no data */
+ Particle *p_data = NULL;
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ int compress = 0;
+ hsize_t nfields;
+ hsize_t start; /* Record to start reading/writing */
+ hsize_t nrecords; /* Number of records to read/write */
+ int i;
+
+ /* Define new values for the field "Pressure" */
+ float pressure_in[NRECORDS_ADD] = {0.0f, 1.0f, 2.0f};
+ int field_index_pre[1] = {3};
+ int field_index_pos[2] = {1, 2};
+
+ /* Define new values for the fields "Latitude,Longitude" */
+ Position position_in[NRECORDS_ADD] = {{0, 0}, {10, 10}, {20, 20}};
+
+ size_t field_sizes_pos[2] = {sizeof(position_in[0].longi), sizeof(position_in[0].lati)};
+
+ size_t field_sizes_pre[1] = {sizeof(float)};
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_05.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make the table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Write the pressure field starting at record 2 */
+ nfields = 1;
+ start = 2;
+ nrecords = NRECORDS_ADD;
+ H5TBwrite_fields_index(file_id, TABLE_NAME, nfields, field_index_pre, start, nrecords, sizeof(float), 0,
+ field_sizes_pre, pressure_in);
+
+ /* Write the new longitude and latitude information starting at record 2 */
+ nfields = 2;
+ start = 2;
+ nrecords = NRECORDS_ADD;
+ H5TBwrite_fields_index(file_id, TABLE_NAME, nfields, field_index_pos, start, nrecords, sizeof(Position),
+ field_offset_pos, field_sizes_pos, position_in);
+
+ /* read the table */
+ H5TBread_table(file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* print it by rows */
+ for (i = 0; i < NRECORDS; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_06.c b/hl/examples/ex_table_06.c
index 0397e83..2784430 100644
--- a/hl/examples/ex_table_06.c
+++ b/hl/examples/ex_table_06.c
@@ -23,73 +23,64 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} }; /* Fill value particle */
- int compress = 0;
- hsize_t nfields_out;
- hsize_t nrecords_out;
-
- /* Initialize field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_06.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make a table */
- H5TBmake_table( "Table Title",file_id,TABLE_NAME,NFIELDS,NRECORDS,dst_size,
- field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, NULL);
-
- /* Get table info */
- H5TBget_table_info (file_id,TABLE_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ int compress = 0;
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+
+ /* Initialize field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_06.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make a table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, NULL);
+
+ /* Get table info */
+ H5TBget_table_info(file_id, TABLE_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_07.c b/hl/examples/ex_table_07.c
index d9ea444..b12cc27 100644
--- a/hl/examples/ex_table_07.c
+++ b/hl/examples/ex_table_07.c
@@ -23,90 +23,77 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
-
- /* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- const char *field_names[NFIELDS] = /* Define field information */
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int compress = 0;
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} };
- hsize_t start; /* Record to start reading */
- hsize_t nrecords; /* Number of records to insert/delete */
- hsize_t nfields_out;
- hsize_t nrecords_out;
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_07.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make the table */
- H5TBmake_table( "Table Title",file_id,TABLE_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Delete records */
- start = 3;
- nrecords = 3;
- H5TBdelete_record( file_id, TABLE_NAME, start, nrecords );
-
- /* Get table info */
- H5TBget_table_info (file_id,TABLE_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ const char *field_names[NFIELDS] = /* Define field information */
+ {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ hsize_t start; /* Record to start reading */
+ hsize_t nrecords; /* Number of records to insert/delete */
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_07.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make the table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Delete records */
+ start = 3;
+ nrecords = 3;
+ H5TBdelete_record(file_id, TABLE_NAME, start, nrecords);
+
+ /* Get table info */
+ H5TBget_table_info(file_id, TABLE_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_08.c b/hl/examples/ex_table_08.c
index a45520d..4210460 100644
--- a/hl/examples/ex_table_08.c
+++ b/hl/examples/ex_table_08.c
@@ -22,121 +22,96 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define NRECORDS_INS (hsize_t) 2
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define NRECORDS_INS (hsize_t)2
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- Particle dst_buf[ NRECORDS + NRECORDS_INS ];
-
- /* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
- size_t dst_sizes[NFIELDS] = { sizeof( p_data[0].name),
- sizeof( p_data[0].lati),
- sizeof( p_data[0].longi),
- sizeof( p_data[0].pressure),
- sizeof( p_data[0].temperature)};
-
- /* Define an array of Particles to insert */
- Particle p_data_insert[NRECORDS_INS] =
- { {"new",30,30, 3.0f, 30.0},
- {"new",40,40, 4.0f, 40.0}
- };
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int compress = 0;
- int *fill_data = NULL;
- hsize_t start; /* Record to start reading */
- hsize_t nrecords; /* Number of records to insert/delete */
- hsize_t nfields_out;
- hsize_t nrecords_out;
- int i;
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_08.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make the table */
- H5TBmake_table( "Table Title",file_id,TABLE_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Insert records */
- start = 3;
- nrecords = NRECORDS_INS;
- H5TBinsert_record( file_id, TABLE_NAME, start, nrecords, dst_size, dst_offset,
- dst_sizes, p_data_insert );
-
- /* read the table */
- H5TBread_table( file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* get table info */
- H5TBget_table_info(file_id,TABLE_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* print it by rows */
- for (i=0; i<nrecords_out; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ Particle dst_buf[NRECORDS + NRECORDS_INS];
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+ size_t dst_sizes[NFIELDS] = {sizeof(p_data[0].name), sizeof(p_data[0].lati), sizeof(p_data[0].longi),
+ sizeof(p_data[0].pressure), sizeof(p_data[0].temperature)};
+
+ /* Define an array of Particles to insert */
+ Particle p_data_insert[NRECORDS_INS] = {{"new", 30, 30, 3.0f, 30.0}, {"new", 40, 40, 4.0f, 40.0}};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ int * fill_data = NULL;
+ hsize_t start; /* Record to start reading */
+ hsize_t nrecords; /* Number of records to insert/delete */
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+ int i;
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_08.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make the table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Insert records */
+ start = 3;
+ nrecords = NRECORDS_INS;
+ H5TBinsert_record(file_id, TABLE_NAME, start, nrecords, dst_size, dst_offset, dst_sizes, p_data_insert);
+
+ /* read the table */
+ H5TBread_table(file_id, TABLE_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* get table info */
+ H5TBget_table_info(file_id, TABLE_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* print it by rows */
+ for (i = 0; i < nrecords_out; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_09.c b/hl/examples/ex_table_09.c
index a9f5f11..5374aff 100644
--- a/hl/examples/ex_table_09.c
+++ b/hl/examples/ex_table_09.c
@@ -22,121 +22,99 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define NRECORDS_INS (hsize_t) 2
-#define TABLE1_NAME "table1"
-#define TABLE2_NAME "table2"
-
-int main( void )
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define NRECORDS_INS (hsize_t)2
+#define TABLE1_NAME "table1"
+#define TABLE2_NAME "table2"
+
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- Particle dst_buf[ NRECORDS + NRECORDS_INS ];
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
- size_t dst_sizes[NFIELDS] = { sizeof( dst_buf[0].name),
- sizeof( dst_buf[0].lati),
- sizeof( dst_buf[0].longi),
- sizeof( dst_buf[0].pressure),
- sizeof( dst_buf[0].temperature)};
-
- /* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int compress = 0;
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} }; /* Fill value particle */
- hsize_t start1; /* Record to start reading from 1st table */
- hsize_t nrecords; /* Number of records to insert */
- hsize_t start2; /* Record to start writing in 2nd table */
- int i;
- hsize_t nfields_out;
- hsize_t nrecords_out;
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_09.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make 2 tables: TABLE2_NAME is empty */
- H5TBmake_table( "Table Title",file_id,TABLE1_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- H5TBmake_table( "Table Title",file_id,TABLE2_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, NULL );
-
-
- /* Add 2 records from TABLE1_NAME to TABLE2_NAME */
- start1 = 3;
- nrecords = NRECORDS_INS;
- start2 = 6;
- H5TBadd_records_from( file_id, TABLE1_NAME, start1, nrecords, TABLE2_NAME, start2 );
-
- /* read TABLE2_NAME: it should have 2 more records now */
- H5TBread_table( file_id, TABLE2_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* Get table info */
- H5TBget_table_info (file_id,TABLE2_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* print it by rows */
- for (i=0; i<nrecords_out; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ Particle dst_buf[NRECORDS + NRECORDS_INS];
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+ size_t dst_sizes[NFIELDS] = {sizeof(dst_buf[0].name), sizeof(dst_buf[0].lati), sizeof(dst_buf[0].longi),
+ sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}}; /* Fill value particle */
+ hsize_t start1; /* Record to start reading from 1st table */
+ hsize_t nrecords; /* Number of records to insert */
+ hsize_t start2; /* Record to start writing in 2nd table */
+ int i;
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_09.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make 2 tables: TABLE2_NAME is empty */
+ H5TBmake_table("Table Title", file_id, TABLE1_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ H5TBmake_table("Table Title", file_id, TABLE2_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, NULL);
+
+ /* Add 2 records from TABLE1_NAME to TABLE2_NAME */
+ start1 = 3;
+ nrecords = NRECORDS_INS;
+ start2 = 6;
+ H5TBadd_records_from(file_id, TABLE1_NAME, start1, nrecords, TABLE2_NAME, start2);
+
+ /* read TABLE2_NAME: it should have 2 more records now */
+ H5TBread_table(file_id, TABLE2_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* Get table info */
+ H5TBget_table_info(file_id, TABLE2_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* print it by rows */
+ for (i = 0; i < nrecords_out; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_10.c b/hl/examples/ex_table_10.c
index 8c4d8ae..754974a 100644
--- a/hl/examples/ex_table_10.c
+++ b/hl/examples/ex_table_10.c
@@ -22,114 +22,92 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define TABLE1_NAME "table1"
-#define TABLE2_NAME "table2"
-#define TABLE3_NAME "table3"
-
-int main( void )
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define TABLE1_NAME "table1"
+#define TABLE2_NAME "table2"
+#define TABLE3_NAME "table3"
+
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- /* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- Particle dst_buf[ 2 * NRECORDS ];
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
- size_t dst_sizes[NFIELDS] = { sizeof( dst_buf[0].name),
- sizeof( dst_buf[0].lati),
- sizeof( dst_buf[0].longi),
- sizeof( dst_buf[0].pressure),
- sizeof( dst_buf[0].temperature)};
-
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int compress = 0;
- int *fill_data = NULL;
- hsize_t nfields_out;
- hsize_t nrecords_out;
- int i;
-
- /* Initialize the field field_type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_10.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make two tables */
- H5TBmake_table( "Table Title",file_id,TABLE1_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- H5TBmake_table( "Table Title",file_id,TABLE2_NAME,NFIELDS,NRECORDS,
- dst_size,field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Combine the two tables into a third in the same file */
- H5TBcombine_tables( file_id, TABLE1_NAME, file_id, TABLE2_NAME, TABLE3_NAME );
-
- /* read the combined table */
- H5TBread_table( file_id, TABLE3_NAME, dst_size, dst_offset, dst_sizes, dst_buf );
-
- /* Get table info */
- H5TBget_table_info (file_id,TABLE3_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* print it by rows */
- for (i=0; i<nrecords_out; i++) {
- printf ("%-5s %-5d %-5d %-5f %-5f",
- dst_buf[i].name,
- dst_buf[i].lati,
- dst_buf[i].longi,
- dst_buf[i].pressure,
- dst_buf[i].temperature);
- printf ("\n");
- }
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ Particle dst_buf[2 * NRECORDS];
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+ size_t dst_sizes[NFIELDS] = {sizeof(dst_buf[0].name), sizeof(dst_buf[0].lati), sizeof(dst_buf[0].longi),
+ sizeof(dst_buf[0].pressure), sizeof(dst_buf[0].temperature)};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ int * fill_data = NULL;
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+ int i;
+
+ /* Initialize the field field_type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_10.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make two tables */
+ H5TBmake_table("Table Title", file_id, TABLE1_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ H5TBmake_table("Table Title", file_id, TABLE2_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Combine the two tables into a third in the same file */
+ H5TBcombine_tables(file_id, TABLE1_NAME, file_id, TABLE2_NAME, TABLE3_NAME);
+
+ /* read the combined table */
+ H5TBread_table(file_id, TABLE3_NAME, dst_size, dst_offset, dst_sizes, dst_buf);
+
+ /* Get table info */
+ H5TBget_table_info(file_id, TABLE3_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* print it by rows */
+ for (i = 0; i < nrecords_out; i++) {
+ printf("%-5s %-5d %-5d %-5f %-5f", dst_buf[i].name, dst_buf[i].lati, dst_buf[i].longi,
+ dst_buf[i].pressure, dst_buf[i].temperature);
+ printf("\n");
+ }
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_11.c b/hl/examples/ex_table_11.c
index d6215cb..4f666b9 100644
--- a/hl/examples/ex_table_11.c
+++ b/hl/examples/ex_table_11.c
@@ -22,95 +22,81 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle1
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle1;
-
-/* Define an array of Particles */
- Particle1 p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size1 = sizeof( Particle1 );
- size_t dst_offset1[NFIELDS] = { HOFFSET( Particle1, name ),
- HOFFSET( Particle1, lati ),
- HOFFSET( Particle1, longi ),
- HOFFSET( Particle1, pressure ),
- HOFFSET( Particle1, temperature )};
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int compress = 0;
- Particle1 fill_data[1] = { {"no data",-1,-1, -99.0f, -99.0} };
- int fill_data_new[1] = { -100 };
- hsize_t position;
- hsize_t nfields_out;
- hsize_t nrecords_out;
-
- /* Define the inserted field information */
- hid_t field_type_new = H5T_NATIVE_INT;
- int data[NRECORDS] = { 0,1,2,3,4,5,6,7 };
-
- /* Initialize the field type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_11.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make the table */
- H5TBmake_table( "Table Title",file_id,TABLE_NAME,NFIELDS,NRECORDS,
- dst_size1,field_names, dst_offset1, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Insert the new field at the end of the field list */
- position = NFIELDS;
- H5TBinsert_field( file_id, TABLE_NAME, "New Field", field_type_new, position,
- fill_data_new, data );
-
- /* Get table info */
- H5TBget_table_info (file_id,TABLE_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
-
+ typedef struct Particle1 {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle1;
+
+ /* Define an array of Particles */
+ Particle1 p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size1 = sizeof(Particle1);
+ size_t dst_offset1[NFIELDS] = {HOFFSET(Particle1, name), HOFFSET(Particle1, lati),
+ HOFFSET(Particle1, longi), HOFFSET(Particle1, pressure),
+ HOFFSET(Particle1, temperature)};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ Particle1 fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ int fill_data_new[1] = {-100};
+ hsize_t position;
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+
+ /* Define the inserted field information */
+ hid_t field_type_new = H5T_NATIVE_INT;
+ int data[NRECORDS] = {0, 1, 2, 3, 4, 5, 6, 7};
+
+ /* Initialize the field type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_11.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make the table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size1, field_names, dst_offset1,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Insert the new field at the end of the field list */
+ position = NFIELDS;
+ H5TBinsert_field(file_id, TABLE_NAME, "New Field", field_type_new, position, fill_data_new, data);
+
+ /* Get table info */
+ H5TBget_table_info(file_id, TABLE_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/ex_table_12.c b/hl/examples/ex_table_12.c
index f287c29..c13401f 100644
--- a/hl/examples/ex_table_12.c
+++ b/hl/examples/ex_table_12.c
@@ -23,87 +23,73 @@
*-------------------------------------------------------------------------
*/
-#define NFIELDS (hsize_t) 5
-#define NRECORDS (hsize_t) 8
-#define TABLE_NAME "table"
+#define NFIELDS (hsize_t)5
+#define NRECORDS (hsize_t)8
+#define TABLE_NAME "table"
-int main( void )
+int
+main(void)
{
- typedef struct Particle
- {
- char name[16];
- int lati;
- int longi;
- float pressure;
- double temperature;
- } Particle;
-
- /* Calculate the size and the offsets of our struct members in memory */
- size_t dst_size = sizeof( Particle );
- size_t dst_offset[NFIELDS] = { HOFFSET( Particle, name ),
- HOFFSET( Particle, lati ),
- HOFFSET( Particle, longi ),
- HOFFSET( Particle, pressure ),
- HOFFSET( Particle, temperature )};
-
- /* Define an array of Particles */
- Particle p_data[NRECORDS] = {
- {"zero",0,0, 0.0f, 0.0},
- {"one",10,10, 1.0f, 10.0},
- {"two", 20,20, 2.0f, 20.0},
- {"three",30,30, 3.0f, 30.0},
- {"four", 40,40, 4.0f, 40.0},
- {"five", 50,50, 5.0f, 50.0},
- {"six", 60,60, 6.0f, 60.0},
- {"seven",70,70, 7.0f, 70.0}
- };
-
- /* Define field information */
- const char *field_names[NFIELDS] =
- { "Name","Latitude", "Longitude", "Pressure", "Temperature" };
- hid_t field_type[NFIELDS];
- hid_t string_type;
- hid_t file_id;
- hsize_t chunk_size = 10;
- int compress = 0;
- Particle fill_data[1] =
- { {"no data",-1,-1, -99.0f, -99.0} };
- hsize_t nfields_out;
- hsize_t nrecords_out;
-
- /* Initialize the field type */
- string_type = H5Tcopy( H5T_C_S1 );
- H5Tset_size( string_type, 16 );
- field_type[0] = string_type;
- field_type[1] = H5T_NATIVE_INT;
- field_type[2] = H5T_NATIVE_INT;
- field_type[3] = H5T_NATIVE_FLOAT;
- field_type[4] = H5T_NATIVE_DOUBLE;
-
- /* Create a new file using default properties. */
- file_id = H5Fcreate( "ex_table_12.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT );
-
- /* Make a table */
- H5TBmake_table( "Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size,
- field_names, dst_offset, field_type,
- chunk_size, fill_data, compress, p_data );
-
- /* Delete the field */
- H5TBdelete_field( file_id, TABLE_NAME, "Pressure" );
-
- /* Get table info */
- H5TBget_table_info (file_id,TABLE_NAME, &nfields_out, &nrecords_out );
-
- /* print */
- printf ("Table has %d fields and %d records\n",(int)nfields_out,(int)nrecords_out);
-
- /* close type */
- H5Tclose( string_type );
-
- /* close the file */
- H5Fclose( file_id );
-
- return 0;
-
+ typedef struct Particle {
+ char name[16];
+ int lati;
+ int longi;
+ float pressure;
+ double temperature;
+ } Particle;
+
+ /* Calculate the size and the offsets of our struct members in memory */
+ size_t dst_size = sizeof(Particle);
+ size_t dst_offset[NFIELDS] = {HOFFSET(Particle, name), HOFFSET(Particle, lati), HOFFSET(Particle, longi),
+ HOFFSET(Particle, pressure), HOFFSET(Particle, temperature)};
+
+ /* Define an array of Particles */
+ Particle p_data[NRECORDS] = {{"zero", 0, 0, 0.0f, 0.0}, {"one", 10, 10, 1.0f, 10.0},
+ {"two", 20, 20, 2.0f, 20.0}, {"three", 30, 30, 3.0f, 30.0},
+ {"four", 40, 40, 4.0f, 40.0}, {"five", 50, 50, 5.0f, 50.0},
+ {"six", 60, 60, 6.0f, 60.0}, {"seven", 70, 70, 7.0f, 70.0}};
+
+ /* Define field information */
+ const char *field_names[NFIELDS] = {"Name", "Latitude", "Longitude", "Pressure", "Temperature"};
+ hid_t field_type[NFIELDS];
+ hid_t string_type;
+ hid_t file_id;
+ hsize_t chunk_size = 10;
+ int compress = 0;
+ Particle fill_data[1] = {{"no data", -1, -1, -99.0f, -99.0}};
+ hsize_t nfields_out;
+ hsize_t nrecords_out;
+
+ /* Initialize the field type */
+ string_type = H5Tcopy(H5T_C_S1);
+ H5Tset_size(string_type, 16);
+ field_type[0] = string_type;
+ field_type[1] = H5T_NATIVE_INT;
+ field_type[2] = H5T_NATIVE_INT;
+ field_type[3] = H5T_NATIVE_FLOAT;
+ field_type[4] = H5T_NATIVE_DOUBLE;
+
+ /* Create a new file using default properties. */
+ file_id = H5Fcreate("ex_table_12.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
+
+ /* Make a table */
+ H5TBmake_table("Table Title", file_id, TABLE_NAME, NFIELDS, NRECORDS, dst_size, field_names, dst_offset,
+ field_type, chunk_size, fill_data, compress, p_data);
+
+ /* Delete the field */
+ H5TBdelete_field(file_id, TABLE_NAME, "Pressure");
+
+ /* Get table info */
+ H5TBget_table_info(file_id, TABLE_NAME, &nfields_out, &nrecords_out);
+
+ /* print */
+ printf("Table has %d fields and %d records\n", (int)nfields_out, (int)nrecords_out);
+
+ /* close type */
+ H5Tclose(string_type);
+
+ /* close the file */
+ H5Fclose(file_id);
+
+ return 0;
}
-
diff --git a/hl/examples/pal_rgb.h b/hl/examples/pal_rgb.h
index 488ee42..137d5d9 100644
--- a/hl/examples/pal_rgb.h
+++ b/hl/examples/pal_rgb.h
@@ -271,10 +271,3 @@ const unsigned char pal_rgb[256*3] = {
127,0,0
};
/* clang-format on */
-
-
-
-
-
-
-
diff --git a/hl/examples/ptExampleFL.c b/hl/examples/ptExampleFL.c
index ba7a3a0..66f2040 100644
--- a/hl/examples/ptExampleFL.c
+++ b/hl/examples/ptExampleFL.c
@@ -23,82 +23,80 @@
*-------------------------------------------------------------------------
*/
-int main(void)
+int
+main(void)
{
- hid_t fid; /* File identifier */
- hid_t ptable; /* Packet table identifier */
+ hid_t fid; /* File identifier */
+ hid_t ptable; /* Packet table identifier */
- herr_t err; /* Function return status */
- hsize_t count; /* Number of records in the table */
+ herr_t err; /* Function return status */
+ hsize_t count; /* Number of records in the table */
- int x; /* Loop variable */
+ int x; /* Loop variable */
/* Buffers to hold data */
- int writeBuffer[5];
- int readBuffer[5];
+ int writeBuffer[5];
+ int readBuffer[5];
- /* Initialize buffers */
- for(x=0; x<5; x++)
- {
- writeBuffer[x]=x;
- readBuffer[x] = -1;
- }
+ /* Initialize buffers */
+ for (x = 0; x < 5; x++) {
+ writeBuffer[x] = x;
+ readBuffer[x] = -1;
+ }
/* Create a file using default properties */
- fid=H5Fcreate("packet_table_FLexample.h5",H5F_ACC_TRUNC,H5P_DEFAULT,H5P_DEFAULT);
+ fid = H5Fcreate("packet_table_FLexample.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
/* Create a fixed-length packet table within the file */
/* This table's "packets" will be simple integers and it will use compression
* level 5. */
- ptable = H5PTcreate_fl(fid, "Packet Test Dataset", H5T_NATIVE_INT, (hsize_t)100, 5);
- if(ptable == H5I_INVALID_HID)
- goto out;
+ ptable = H5PTcreate_fl(fid, "Packet Test Dataset", H5T_NATIVE_INT, (hsize_t)100, 5);
+ if (ptable == H5I_INVALID_HID)
+ goto out;
/* Write one packet to the packet table */
- err = H5PTappend(ptable, (hsize_t)1, &(writeBuffer[0]) );
- if(err < 0)
- goto out;
+ err = H5PTappend(ptable, (hsize_t)1, &(writeBuffer[0]));
+ if (err < 0)
+ goto out;
/* Write several packets to the packet table */
- err = H5PTappend(ptable, (hsize_t)4, &(writeBuffer[1]) );
- if(err < 0)
- goto out;
+ err = H5PTappend(ptable, (hsize_t)4, &(writeBuffer[1]));
+ if (err < 0)
+ goto out;
/* Get the number of packets in the packet table. This should be five. */
- err = H5PTget_num_packets(ptable, &count);
- if(err < 0)
- goto out;
+ err = H5PTget_num_packets(ptable, &count);
+ if (err < 0)
+ goto out;
- printf("Number of packets in packet table after five appends: %d\n", (int)count);
+ printf("Number of packets in packet table after five appends: %d\n", (int)count);
/* Initialize packet table's "current record" */
- err = H5PTcreate_index(ptable);
- if(err < 0)
- goto out;
+ err = H5PTcreate_index(ptable);
+ if (err < 0)
+ goto out;
/* Iterate through packets, read each one back */
- for(x=0; x<5; x++)
- {
- err = H5PTget_next(ptable, (hsize_t)1, &(readBuffer[x]) );
- if(err < 0)
- goto out;
+ for (x = 0; x < 5; x++) {
+ err = H5PTget_next(ptable, (hsize_t)1, &(readBuffer[x]));
+ if (err < 0)
+ goto out;
- printf("Packet %d's value is %d\n", x, readBuffer[x]);
- }
+ printf("Packet %d's value is %d\n", x, readBuffer[x]);
+ }
/* Close the packet table */
- err = H5PTclose(ptable);
- if(err < 0)
- goto out;
+ err = H5PTclose(ptable);
+ if (err < 0)
+ goto out;
/* Close the file */
- H5Fclose(fid);
+ H5Fclose(fid);
- return 0;
+ return 0;
- out: /* An error has occurred. Clean up and exit. */
+out: /* An error has occurred. Clean up and exit. */
H5PTclose(ptable);
H5Fclose(fid);
return -1;
}
-