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" { DATATYPE H5T_STRING { STRSIZE 431; STRPAD H5T_STR_NULLTERM; CSET H5T_CSET_ASCII; CTYPE H5T_C_S1; } DATASPACE SCALAR 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 HDF5. 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. Thanks, Ed -- Ed Hartnett -- ed@xxxxxxxxxxxxxxxx
netcdf-hdf
archives: