/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by the Board of Trustees of the University of Illinois. * * All rights reserved. * * * * This file is part of HDF5. The full HDF5 copyright notice, including * * terms governing use, modification, and redistribution, is contained in * * the files COPYING and Copyright.html. COPYING can be found at the root * * of the source code distribution tree; Copyright.html can be found at the * * root level of an installed copy of the electronic HDF5 document set and * * is linked from the top-level documents page. It can also be found at * * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /*********************************************************** * * Test program: trefer * * Test the Reference functionality * *************************************************************/ #include "testhdf5.h" #include "hdf5.h" #define FILE1 "trefer1.h5" #define FILE2 "trefer2.h5" #define FILE3 "trefer3.h5" /* 1-D dataset with fixed dimensions */ #define SPACE1_NAME "Space1" #define SPACE1_RANK 1 #define SPACE1_DIM1 4 /* 2-D dataset with fixed dimensions */ #define SPACE2_NAME "Space2" #define SPACE2_RANK 2 #define SPACE2_DIM1 10 #define SPACE2_DIM2 10 /* Larger 1-D dataset with fixed dimensions */ #define SPACE3_NAME "Space3" #define SPACE3_RANK 1 #define SPACE3_DIM1 100 /* Element selection information */ #define POINT1_NPOINTS 10 /* Compound datatype */ typedef struct s1_t { unsigned int a; unsigned int b; float c; } s1_t; /**************************************************************** ** ** test_reference_obj(): Test basic H5R (reference) object reference code. ** Tests references to various kinds of objects ** ****************************************************************/ static void test_reference_obj(void) { hid_t fid1; /* HDF5 File IDs */ hid_t dataset, /* Dataset ID */ dset2; /* Dereferenced dataset ID */ hid_t group; /* Group ID */ hid_t sid1; /* Dataspace ID */ hid_t tid1; /* Datatype ID */ hsize_t dims1[] = {SPACE1_DIM1}; hobj_ref_t *wbuf, /* buffer to write to disk */ *rbuf, /* buffer read from disk */ *tbuf; /* temp. buffer read from disk */ unsigned *tu32; /* Temporary pointer to uint32 data */ int i; /* counting variables */ const char *write_comment="Foo!"; /* Comments for group */ char read_comment[10]; herr_t ret; /* Generic return value */ /* Output message about test being performed */ MESSAGE(5, ("Testing Object Reference Functions\n")); /* Allocate write & read buffers */ wbuf=malloc(MAX(sizeof(unsigned),sizeof(hobj_ref_t))*SPACE1_DIM1); rbuf=malloc(MAX(sizeof(unsigned),sizeof(hobj_ref_t))*SPACE1_DIM1); tbuf=malloc(MAX(sizeof(unsigned),sizeof(hobj_ref_t))*SPACE1_DIM1); /* Create file */ fid1 = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid1, FAIL, "H5Fcreate"); /* Create dataspace for datasets */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); CHECK(sid1, FAIL, "H5Screate_simple"); /* Create a group */ group=H5Gcreate(fid1,"Group1",(size_t)-1); CHECK(group, FAIL, "H5Gcreate"); /* Set group's comment */ ret=H5Gset_comment(group,".",write_comment); CHECK(ret, FAIL, "H5Gset_comment"); /* Create a dataset (inside Group1) */ dataset=H5Dcreate(group,"Dataset1",H5T_NATIVE_UINT,sid1,H5P_DEFAULT); CHECK(dataset, FAIL, "H5Dcreate"); for(tu32=(unsigned *)wbuf,i=0; i