/************************************************************ This example shows how to read and write enumerated datatypes to an attribute. The program first writes enumerated values to an attribute with a dataspace of DIM0xDIM1, then closes the file. Next, it reopens the file, reads back the data, and outputs it to the screen. This file is intended for use with HDF5 Library version 1.6 ************************************************************/ #include "hdf5.h" #include #include #define FILE "h5ex_t_enumatt.h5" #define DATASET "DS1" #define ATTRIBUTE "A1" #define DIM0 4 #define DIM1 7 #define F_BASET H5T_STD_I16BE /* File base type */ #define M_BASET H5T_NATIVE_INT /* Memory base type */ #define NAME_BUF_SIZE 16 typedef enum { SOLID, LIQUID, GAS, PLASMA } phase_t; /* Enumerated type */ int main (void) { hid_t file, filetype, memtype, space, dset, attr; /* Handles */ herr_t status; hsize_t dims[2] = {DIM0, DIM1}; phase_t wdata[DIM0][DIM1], /* Write buffer */ **rdata, /* Read buffer */ val; char *names[4] = {"SOLID", "LIQUID", "GAS", "PLASMA"}, name[NAME_BUF_SIZE]; int ndims, i, j; /* * Initialize data. */ for (i=0; i