/* This is part of the netCDF package. Copyright 2005 University Corporation for Atmospheric Research/Unidata See COPYRIGHT file for conditions of use. This program excersizes HDF5 variable length array code. $Id: tst_h_enums.c,v 1.14 2010/06/01 15:34:51 ed Exp $ */ #include "h5_err_macros.h" #include #include "config.h" #define FILE_NAME "tst_h_enums.h5" #define DIM1_LEN 12 #define ATT_NAME "Browings_reverse_enumerations" #define SIZE 9 #define GRP_NAME "Browning" #define NUM_VALS 12 #define STR_LEN 255 /* This seems like a good sonnet for enumation: How do I love thee? Let me count the ways. I love thee to the depth and breadth and height My soul can reach, when feeling out of sight For the ends of Being and ideal Grace. I love thee to the level of everyday's Most quiet need, by sun and candle-light. I love thee freely, as men strive for Right; I love thee purely, as they turn from Praise. I love thee with a passion put to use In my old griefs, and with my childhood's faith. I love thee with a love I seemed to lose With my lost saints, --- I love thee with the breath, Smiles, tears, of all my life! --- and, if God choose, I shall but love thee better after death. (I gotta say, that's one dorky poem. - Ed) */ int main() { printf("\n*** Checking HDF5 enum types.\n"); printf("*** Checking simple HDF5 enum type..."); { hid_t fileid, grpid, spaceid, typeid, attid; hsize_t dims[1] = {DIM1_LEN}; short data[DIM1_LEN]; short data_in[DIM1_LEN]; int i; short val[NUM_VALS]; char love_how[NUM_VALS][STR_LEN + 1] = {"Depth", "Breadth", "Height", "Level", "Freely", "Purely", "Passionately", "Lost", "Breath", "Smiles", "Tears", "After Death"}; /* H5T_class_t type_class;*/ size_t size; int num_members; short the_value; char *member_name; htri_t types_equal; hid_t base_hdf_typeid; for (i=0; i < NUM_VALS; i++) val[i] = i*2; for (i=0; i < DIM1_LEN; i++) data[i] = i*2; /* Open file. */ if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) ERR; if ((grpid = H5Gcreate(fileid, GRP_NAME, 0)) < 0) ERR; /* Create enum type. */ /* Both methods do the same thing, but Quincey says to prefer * H5Tcreate_enum. */ /*if ((typeid = H5Tcreate(H5T_ENUM, sizeof(short))) < 0) ERR;*/ if ((typeid = H5Tenum_create(H5T_NATIVE_SHORT)) < 0) ERR; /* Insert some values. */ for (i=0; i