/* This is part of the netCDF package. Copyright 2018 University Corporation for Atmospheric Research/Unidata See COPYRIGHT file for conditions of use. Test HDF5 file code. These are not intended to be exhaustive tests, but they use HDF5 the same way that netCDF-4 does, so if these tests don't work, than netCDF-4 won't work either. This program deals with HDF5 compound types. $Id: tst_h_compounds.c,v 1.25 2010/06/01 15:34:51 ed Exp $ */ #include "h5_err_macros.h" #include #define FILE_NAME "tst_h_compounds.h5" #define DIM1_LEN 3 #define OSMONDS "TheOsmonds" #define WHO "TheWho" #define BOOZE_VAR "Alcohol_Consumed" #define BEER_OR_WINE "Beer_or_Wine" #define LIQUOR "The_Hard_Stuff" #define COMPOUND_NAME "Booze_Index" #define ARRAY_LEN 5 #define STR_LEN 255 int main() { hid_t fileid, osmonds_grpid, who_grpid, spaceid, typeid; hid_t datasetid, datasetid1, typeid1; hsize_t dims[1]; struct s1 { int i1, i2; } data[DIM1_LEN]; struct s2 { int i1[ARRAY_LEN], i2; } data2[DIM1_LEN]; char *dummy; int i, j; /* REALLY initialize the data (even the gaps in the structs). This * is only needed to pass valgrind. */ if (!(dummy = calloc(sizeof(struct s2), DIM1_LEN))) ERR; memcpy((void *)data2, (void *)dummy, sizeof(struct s2) * DIM1_LEN); free(dummy); if (!(dummy = calloc(sizeof(struct s1), DIM1_LEN))) ERR; memcpy((void *)data2, (void *)dummy, sizeof(struct s1) * DIM1_LEN); free(dummy); for (i=0; i