0
注意的表更新單元格:交會上http://mail.lists.hdfgroup.org/pipermail/hdf-forum_lists.hdfgroup.org/2014-July/007960.htmlHDF5:在整數
發佈使用HDF5,我建了一個5x4
表。表中的每個單元格都包含3 integers
我正在嘗試編寫一個函數setyx將更新表格的單元格y,x
這是我迄今編寫的C代碼。
#include "hdf5.h"
/** set 3 'int' values at y/x */
static void setyx(hid_t dataset, hid_t dataspace,
int y,int x,
int i1,int i2,int i3)
{
int values[3]={i1,i2,i3};
hsize_t starts[3]={y,x,0};
hsize_t counts[3]={1,1,1};
hsize_t dims_memory[3]={1,1,3};
H5Sselect_hyperslab(dataspace, H5S_SELECT_SET, starts, NULL, counts, NULL);
hid_t filespace = H5Dget_space(dataset);
hid_t memspace = H5Screate_simple(3, dims_memory, NULL);
H5Dwrite(dataset,
H5T_NATIVE_INT,
memspace,
filespace,
H5P_DEFAULT,
values);
H5Sclose(memspace);
H5Sclose(filespace);
}
int main (void)
{
hid_t file, dataset;
hid_t dataspace;
hsize_t dims[3]={5,4,3};
file = H5Fcreate("test.h5", H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
dataspace = H5Screate_simple(3, dims, NULL);
dataset = H5Dcreate(file, "/test", H5T_NATIVE_INT, dataspace,
H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
setyx(dataset,dataspace,2,1, 100,200,300);
H5Sclose(dataspace);
H5Dclose(dataset);
H5Fclose(file);
return 0;
}
,但它提出了一些錯誤:
#000: H5Dio.c line 225 in H5Dwrite(): can't prepare for writing data
major: Dataset
minor: Write failed
#001: H5Dio.c line 347 in H5D__pre_write(): can't write data
major: Dataset
minor: Write failed
#002: H5Dio.c line 685 in H5D__write(): src and dest data spaces have different sizes
major: Invalid arguments to routine
minor: Bad value
什麼是(y,x)
更新定單元的正確方法是什麼?