Re: scalar string attribute question...

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

Elena Pourmal <epourmal@xxxxxxxxxxxxx> writes:

> 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?

No, I am trying to write a scalar attribute, of type string.

That is, I have one string, and I want to store it in an attribute.

If I don't set the length, I get a zero-length string. If I set it to
H5T_VARIABLE I get a seg fault. If I set it to the string length I get
what I want:

HDF5 "tst_h_atts.h5" {
GROUP "/" {
   ATTRIBUTE "Hamlets_Self_Evaluation" {
            STRSIZE 431;
            CSET H5T_CSET_ASCII;
            CTYPE H5T_C_S1;
      DATA {
      (0): "O, what a rogue and peasant slave am I!
           Is it not monstrous that this player here,
           But in a fiction, in a dream of passion,
           Could force his soul so to his own conceit
           That from her working all his visage wann'd,
           Tears in his eyes, distraction in's aspect,
           A broken voice, and his whole function suiting
           With forms to his conceit? and all for nothing!
           For Hecuba!
           What's Hecuba to him, or he to Hecuba,
           That he should weep for her?"

But then when I read it, I am not getting space allocated by HDF5. I
am (seemingly) allocating my own space and freeing it too, without

That seems to violate the rules for string types, which is that HDF5
allocates the storage for the contents of the string when I read the
string from the file.



Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx

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