Re: scalar string attribute question...

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

Hi Add,

No, you do not need to give a length string.

Why you are using scalar dataspace? Your attribute is an array of strings, right?

At 09:19 AM 9/13/2005, Ed Hartnett wrote:
Elena Pourmal <epourmal@xxxxxxxxxxxxx> writes:

> Ed,
>
> You have to use
> H5Tset_size (typeid,H5T_VARIABLE) instead of H5Tset_size(typeid, strlen(txt))
>
> Elena

When I try this I get a seg fault when I reach H5Awrite...

The question is, do I have to tell HDF5 the length of a string in a
scalar string attribute?

Thanks!

Ed

   /* See if we can write an attribute to the root group. */
   if ((fileid = H5Fcreate(FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT,
                           H5P_DEFAULT)) < 0) ERR;
   if ((grpid = H5Gopen(fileid, "/")) < 0) ERR;

   /* Attach a text attribute with some of Hamlet's lines. */
   if ((spaceid = H5Screate(H5S_SCALAR)) < 0) ERR;
   if ((typeid = H5Tcopy(H5T_C_S1)) < 0) ERR;
   if (H5Tset_size(typeid, H5T_VARIABLE) < 0) ERR;
   if ((attid = H5Acreate(grpid, ATT1_NAME, typeid, spaceid,
                          H5P_DEFAULT)) < 0) ERR;
   if (H5Awrite(attid, typeid, txt) < 0) ERR;

--
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

-----------------------------------------------------------------------------------------------
Elena Pourmal, HDF QA, Maintenance and Support Team Leader
NCSA University of Illinois at Urbana-Champaign
605 E. Springfield Ave.
Champaign, IL 61820

epourmal@xxxxxxxxxxxxx
(217)333-0238 (office)
(217)244-1987 (fax)
----------------------------------------------------------------------------------------------



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