Hi Ed,
> Quincey Koziol <koziol@xxxxxxxxxxxxx> writes:
>
> > You are probably running into alignment issues. Try using
> > sizeof(struct s1)
> > instead of '8' for the compound dataype's size and using HOFFSET(struct s1,
> > i1),
> > etc. for the offsets of the fields.
> >
>
> Nope, I made the changes you suggest, still no joy...
Hmm, it looks like you haven't initialized your loop counter ('i') to zero,
try that and see if it helps.
Quincey
>
> #include "tests.h"
>
> #define FILE_NAME "tst_h_compounds.h5"
> #define DIM1_LEN 3
> #define GRP_NAME "group1"
> #define VAR1_NAME "v1"
> #define FIELD1_NAME "f1"
> #define FIELD2_NAME "f2"
> #define COMPOUND_NAME "compound_type_1"
>
> int
> main()
> {
> hid_t fileid, grpid, spaceid, typeid, datasetid;
> int bool_out[DIM1_LEN] = {0, 1, 0}, bool_in[DIM1_LEN];
> hsize_t dims[1];
> struct s1 {
> int i1, i2;
> } data[DIM1_LEN];
> int i;
>
> printf("*** Checking HDF5 compound types...");
>
> for (i; i<DIM1_LEN; i++)
> {
> data[i].i1 = 99;
> data[i].i2 = -99;
> }
>
> /* Open file and create group. */
> if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
> H5P_DEFAULT)) < 0) ERR;
> if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR;
>
> /* Create a simple compound type. */
> if ((typeid = H5Tcreate(H5T_COMPOUND, sizeof(struct s1)))) ERR;
> if (H5Tinsert(typeid, FIELD1_NAME, HOFFSET(struct s1, i1), H5T_NATIVE_INT)
> < 0) ERR;
> if (H5Tinsert(typeid, FIELD2_NAME, HOFFSET(struct s1, i2), H5T_NATIVE_INT)
> < 0) ERR;
> if (H5Tcommit(grpid, COMPOUND_NAME, typeid)) ERR;
>
> /* Create a space. */
> dims[0] = DIM1_LEN;
> if ((spaceid = H5Screate_simple(1, dims, dims)) < 0) ERR;
>
> /* Create a dataset of this compound type. */
> if ((datasetid = H5Dcreate(grpid, VAR1_NAME, typeid,
> spaceid, H5P_DEFAULT)) < 0) ERR;
>
> if (H5Dwrite(datasetid, typeid, H5S_ALL, H5S_ALL,
> H5P_DEFAULT, data) < 0) ERR;
>
> if (H5Dclose(datasetid) < 0 ||
> H5Tclose(typeid) < 0 ||
> H5Sclose(spaceid) < 0 ||
> H5Gclose(grpid) < 0 ||
> H5Fclose(fileid) < 0) ERR;
>
> SUMMARIZE_ERR;
>
> return 0;
> }
>
>
> HDF5 "tst_h_compounds.h5" {
> GROUP "/" {
> GROUP "group1" {
> DATATYPE "compound_type_1" H5T_COMPOUND {
> H5T_STD_I32LE "f1";
> H5T_STD_I32LE "f2";
> }
> DATASET "v1" {
> DATATYPE "/group1/compound_type_1"
> DATASPACE SIMPLE { ( 3 ) / ( 3 ) }
> DATA {
> (0): {
> 0,
> 0
> },
> (1): {
> 24641422,
> -1073743792
> },
> (2): {
> 10151160,
> 0
> }
> }
> }
> }
> }
> }
>
> --
> Ed Hartnett -- ed@xxxxxxxxxxxxxxxx
>