what I am doing wrong with fill values for HDF5 strings...

NOTE: The netcdf-hdf mailing list is no longer active. The list archives are made available for historical reasons.

Howdy HDF5 Folk!

I can't get a fill_value working for a string type - I don't know why.

I have the following code, it sets up a string variable with fill
value. But it does not work!

   printf("*** Checking fill value...");
   {
#define NUM_AMENDMENTS 27
#define NA 2
#define MAX_LEN 1024
#define GRP_NAME1 "Constitution"
#define VAR_NAME1 "Amendments"

      char *data[NA];
      char **data_in;
      char amend[NA][MAX_LEN] = {"Congress shall make no law respecting an "
                                 "establishment of religion, or prohibiting the 
"
                                 "free exercise thereof; or abridging the 
freedom "
                                 "of speech, or of the press; or the right of 
the "
                                 "people peaceably to assemble, and to petition 
"
                                 "the government for a redress of grievances.", 
                                 " A well regulated militia, being necessary to 
the "
                                 "security of a free state, the right of the 
people "
                                 "to keep and bear arms, shall not be 
infringed."};
      hsize_t dims_in[1], dims[1] = {NA};
      hid_t fileid, grpid, spaceid, typeid, datasetid, plistid;
      int i;
      char fill_value[] = "";
      char *f1 = fill_value;

      for (i = 0; i < NA; i++)
         data[i] = amend[i];

      /* Open file. */
      if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, 
                           H5P_DEFAULT)) < 0) ERR;
      if ((grpid = H5Gcreate(fileid, GRP_NAME1, 0)) < 0) ERR;
      
      /* Create string type. */
      if ((typeid =  H5Tcopy(H5T_C_S1)) < 0) ERR;
      if (H5Tset_size(typeid, H5T_VARIABLE) < 0) ERR;
      
      /* Write an dataset of this type. */
      if ((spaceid = H5Screate_simple(1, dims, NULL)) < 0) ERR;
      if ((plistid = H5Pcreate(H5P_DATASET_CREATE)) < 0) ERR;
      if (H5Pset_fill_value(plistid, typeid, f1) < 0) ERR;
      if ((datasetid = H5Dcreate(grpid, VAR_NAME1, typeid, 
                                 spaceid, plistid)) < 0) ERR;
      if (H5Dwrite(datasetid, typeid, H5S_ALL, H5S_ALL, H5P_DEFAULT, 
                   data) < 0) ERR;

When it gets to here I get an error from HDF5:


Program received signal SIGSEGV, Segmentation fault.
0x00000000006dad95 in H5T_vlen_str_mem_getlen (_vl=0x9d0d50) at H5Tvlen.c:532




-- 
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

==============================================================================
To unsubscribe netcdf-hdf, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdf-hdf archives: