c - HDF5 Attribute unsigned long long value -


when try , add unsigned long long attribute dataset, attribute added not value. using similiar method integer seems work file.

am using hdf view view attributes. attribute names displayed, unsigned long long attributes, values not visible

the code follows:

    herr_t result;  //open file hid_t datafile = h5fopen(filename, h5f_acc_rdwr, h5p_default);  //open dataset hid_t dataset = h5dopen2(datafile, "/summary", h5p_default);  //create data space attribute. hsize_t attributedims = 1; hid_t attributedataspace = h5screate_simple(1, &attributedims , null); hid_t attribute;  //attribute 1: fail write long long attribute attribute = h5acreate2 (dataset, "longattribute",  h5t_std_u64be, attributedataspace, h5p_default, h5p_default); if (attribute < 0) {     fprintf(stdout, "failed add unsigned long long attribute file %s.", filename);     return false; }  //write attribute data unsigned long long* ullattribute = (unsigned long long*) malloc(sizeof(unsigned long long) * 1); ullattribute[0] = (unsigned long long) 4; result = h5awrite(attribute, h5t_native_ullong, ullattribute); if (result < 0) {     fprintf(stdout, "failed write unsigned long long attribute file %s.", filename);     return false; }  //attribute 2: succesfully write integer attribute attribute = h5acreate2 (dataset, "intattribute",  h5t_std_i32be, attributedataspace, h5p_default, h5p_default); if (attribute < 0) {     fprintf(stdout, "failed create attribute file %s.", filename);     return false; }  //write attribute data int32_t* iattribute = (int32_t*) malloc(sizeof(int32_t) * 1); iattribute[0] = (int32_t) 4; result = h5awrite(attribute,  h5t_native_int, iattribute); if (result < 0) {     fprintf(stdout, "failed add integer attribute file %s.", filename);     return false; }  //close attribute, dataset , datafile result = h5aclose(attribute); result = h5dclose(dataset); result = h5fclose(datafile); 

no error messages displayed when code executed, when hdf5 file viewed, both attributes, "intattribute" , "longattribute" visible, longattribute has no value.

hfview 2.9, fedora 20 on intel 64.

picking of timothy's question's wrt: how come creating simple dataspace attribute? chewing on storing model parameters attributes, kinda key-value-pairs. many of model parameters simple scalar values.

wrt: following same lines, how come writing array attribute? i'd edited example, had stored 2 values in array. see example, you've malloc()'ed space, i'll use on seems more clear.

wrt: on intel 64, yet wanting write big endian? yes: still puzzels me: both h5t_std_i32be , h5t_std_i32le work successfully, neither h5t_std_u64be nor h5t_std_u64le show value in hdfview. guess somewhere in hdf5 library it's checking big vs little endian , handling value accordingly, regardless of parameter. i'll try not trip on "feature" later postgresql binary numbers big endian values.

the issue appears in hdfview, still not displaying unsigned long long in ull.h5 file produced timothy's code, or code:enter image description here

i'm using hdfview 2.9 linux. timothy mentioned works in hdfview 2.10 i'll use h5dump in meantime.

a couple of questions, should fine, i'm curious.

  1. how come creating simple dataspace attribute?
  2. following same lines, how come writing array attribute?
  3. your on intel 64, yet wanting write big endian?

here's simple example of writing attribute using scalar dataspace:

#include <stdio.h> #include <stdlib.h> #include <hdf5.h>  int main(int argc, char **argv) {         unsigned long long *ull = null;         hid_t f_id = {0};         hid_t d_id = {0};         hid_t s_id = {0};         hid_t a_id = {0};         hid_t as_id = {0};         hsize_t dims[2] = {2, 2};         herr_t status = {0};          f_id = h5fcreate("ull.h5",h5f_acc_trunc, h5p_default, h5p_default);         s_id = h5screate_simple(2, dims, null);         d_id = h5dcreate(f_id, "/data", h5t_std_i32be, s_id,                          h5p_default, h5p_default, h5p_default);          as_id = h5screate(h5s_scalar);         a_id = h5acreate(d_id, "unsigned long long", h5t_std_u64le,                          as_id, h5p_default, h5p_default);          ull = malloc(sizeof(unsigned long long));         *ull = 123;         status = h5awrite(a_id, h5t_native_ullong, ull);          status = h5aclose(a_id);         status = h5dclose(d_id);         status = h5sclose(s_id);         status = h5fclose(f_id);          return(exit_success); } 

when compiled , run:

h5pcc -o test test.c && ./test && h5dump ull.h5 

i see fine:

hdf5 "ull.h5" { group "/" {    dataset "data" {       datatype  h5t_std_i32be       dataspace  simple { ( 2, 2 ) / ( 2, 2 ) }       data {       (0,0): 0, 0,       (1,0): 0, 0       }       attribute "unsigned long long" {          datatype  h5t_std_u64le          dataspace  scalar          data {          (0): 1234          }       }    } } } 

of course if change scalar attribute dataspace simple dataspace still works:

as_id = h5screate_simple(1, adims, null); a_id = h5acreate(d_id, "unsigned long long", h5t_std_u64le,                  as_id, h5p_default, h5p_default); ull = malloc(sizeof(unsigned long long)); *ull = 123; 

we get:

  attribute "unsigned long long" {      datatype  h5t_std_u64le      dataspace  simple { ( 1 ) / ( 1 ) }      data {      (0): 123      } 

right after long winded example of how can done. looking @ code, can't find error. in fact using code on empty hdf5 file works:

localhost ~$ h5dump ull.h5 hdf5 "ull.h5" { group "/" {    dataset "summary" {       datatype  h5t_std_i32be       dataspace  simple { ( 2, 2 ) / ( 2, 2 ) }       data {       (0,0): 0, 0,       (1,0): 0, 0       }    } } } localhost ~$ ./foo localhost ~$ h5dump ull.h5 hdf5 "ull.h5" { group "/" {    dataset "summary" {       datatype  h5t_std_i32be       dataspace  simple { ( 2, 2 ) / ( 2, 2 ) }       data {       (0,0): 0, 0,       (1,0): 0, 0       }       attribute "intattribute" {          datatype  h5t_std_i32be          dataspace  simple { ( 1 ) / ( 1 ) }          data {          (0): 4          }       }       attribute "longattribute" {          datatype  h5t_std_u64be          dataspace  simple { ( 1 ) / ( 1 ) }          data {          (0): 4          }       }    } } } 

can check (and post) h5dump gives you? maybe issue in using hdfview?


update

i had @ file hdfview (version 2.10) , seems fine. hdfview inspection of attributes

can confirm/re-create error?


Comments

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -