SHOGUN v0.9.0
|
00001 /* 00002 * This program is free software; you can redistribute it and/or modify 00003 * it under the terms of the GNU General Public License as published by 00004 * the Free Software Foundation; either version 3 of the License, or 00005 * (at your option) any later version. 00006 * 00007 * Written (W) 2010 Soeren Sonnenburg 00008 * Copyright (C) 2010 Berlin Institute of Technology 00009 */ 00010 00011 #include <shogun/lib/config.h> 00012 00013 #ifdef HAVE_HDF5 00014 #include <stdio.h> 00015 #include <stdlib.h> 00016 #include <string.h> 00017 #include <hdf5.h> 00018 00019 #include "lib/HDF5File.h" 00020 00021 #include "features/StringFeatures.h" 00022 #include "features/SparseFeatures.h" 00023 00024 using namespace shogun; 00025 00026 CHDF5File::CHDF5File(void) 00027 { 00028 SG_UNSTABLE("CHDF5File::CHDF5File(void)", "\n"); 00029 00030 get_boolean_type(); 00031 h5file = -1; 00032 } 00033 00034 CHDF5File::CHDF5File(char* fname, char rw, const char* name) : CFile() 00035 { 00036 get_boolean_type(); 00037 H5Eset_auto(NULL, NULL); 00038 00039 if (name) 00040 set_variable_name(name); 00041 00042 switch (rw) 00043 { 00044 case 'r': 00045 h5file = H5Fopen(fname, H5F_ACC_RDONLY, H5P_DEFAULT); 00046 break; 00047 case 'w': 00048 h5file = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 00049 break; 00050 case 'a': 00051 h5file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); 00052 if (h5file <0) 00053 h5file = H5Fcreate(fname, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); 00054 break; 00055 default: 00056 SG_ERROR("unknown mode '%c'\n", rw); 00057 }; 00058 00059 if (h5file<0) 00060 SG_ERROR("Could not open file '%s'\n", fname); 00061 } 00062 00063 CHDF5File::~CHDF5File() 00064 { 00065 H5Fclose(h5file); 00066 } 00067 00068 #define GET_VECTOR(fname, sg_type, datatype) \ 00069 void CHDF5File::fname(sg_type*& vec, int32_t& len) \ 00070 { \ 00071 if (!h5file) \ 00072 SG_ERROR("File invalid.\n"); \ 00073 \ 00074 int32_t* dims; \ 00075 int32_t ndims; \ 00076 int64_t nelements; \ 00077 hid_t dataset = H5Dopen(h5file, variable_name); \ 00078 if (dataset<0) \ 00079 SG_ERROR("Error opening data set\n"); \ 00080 hid_t dtype = H5Dget_type(dataset); \ 00081 H5T_class_t t_class=H5Tget_class(dtype); \ 00082 TSGDataType t datatype; hid_t h5_type=get_compatible_type(t_class, &t); \ 00083 if (h5_type==-1) \ 00084 { \ 00085 H5Dclose(dataset); \ 00086 SG_INFO("No compatible datatype found\n"); \ 00087 } \ 00088 get_dims(dataset, dims, ndims, nelements); \ 00089 if (!((ndims==2 && dims[0]==nelements && dims[1]==1) || \ 00090 (ndims==2 && dims[0]==1 && dims[1]==nelements) || \ 00091 (ndims==1 && dims[0]==nelements))) \ 00092 SG_ERROR("Error not a 1-dimensional vector (ndims=%d, dims[0]=%d)\n", ndims, dims[0]); \ 00093 vec=new sg_type[nelements]; \ 00094 len=nelements; \ 00095 herr_t status = H5Dread(dataset, h5_type, H5S_ALL, \ 00096 H5S_ALL, H5P_DEFAULT, vec); \ 00097 H5Dclose(dataset); \ 00098 H5Tclose(dtype); \ 00099 delete[] dims; \ 00100 if (status<0) \ 00101 { \ 00102 delete[] vec; \ 00103 SG_ERROR("Error reading dataset\n"); \ 00104 } \ 00105 } 00106 00107 GET_VECTOR(get_bool_vector, bool, (CT_VECTOR, ST_NONE, PT_BOOL)) 00108 GET_VECTOR(get_byte_vector, uint8_t, (CT_VECTOR, ST_NONE, PT_UINT8)) 00109 GET_VECTOR(get_char_vector, char, (CT_VECTOR, ST_NONE, PT_CHAR)) 00110 GET_VECTOR(get_int_vector, int32_t, (CT_VECTOR, ST_NONE, PT_INT32)) 00111 GET_VECTOR(get_shortreal_vector, float32_t, (CT_VECTOR, ST_NONE, PT_FLOAT32)) 00112 GET_VECTOR(get_real_vector, float64_t, (CT_VECTOR, ST_NONE, PT_FLOAT64)) 00113 GET_VECTOR(get_short_vector, int16_t, (CT_VECTOR, ST_NONE, PT_INT16)) 00114 GET_VECTOR(get_word_vector, uint16_t, (CT_VECTOR, ST_NONE, PT_INT16)) 00115 #undef GET_VECTOR 00116 00117 #define GET_MATRIX(fname, sg_type, datatype) \ 00118 void CHDF5File::fname(sg_type*& matrix, int32_t& num_feat, int32_t& num_vec) \ 00119 { \ 00120 if (!h5file) \ 00121 SG_ERROR("File invalid.\n"); \ 00122 \ 00123 int32_t* dims; \ 00124 int32_t ndims; \ 00125 int64_t nelements; \ 00126 hid_t dataset = H5Dopen(h5file, variable_name); \ 00127 if (dataset<0) \ 00128 SG_ERROR("Error opening data set\n"); \ 00129 hid_t dtype = H5Dget_type(dataset); \ 00130 H5T_class_t t_class=H5Tget_class(dtype); \ 00131 TSGDataType t datatype; hid_t h5_type=get_compatible_type(t_class, &t); \ 00132 if (h5_type==-1) \ 00133 { \ 00134 H5Dclose(dataset); \ 00135 SG_INFO("No compatible datatype found\n"); \ 00136 } \ 00137 get_dims(dataset, dims, ndims, nelements); \ 00138 if (ndims!=2) \ 00139 SG_ERROR("Error not a 2-dimensional matrix\n"); \ 00140 matrix=new sg_type[nelements]; \ 00141 num_feat=dims[0]; \ 00142 num_vec=dims[1]; \ 00143 herr_t status = H5Dread(dataset, h5_type, H5S_ALL, \ 00144 H5S_ALL, H5P_DEFAULT, matrix); \ 00145 H5Dclose(dataset); \ 00146 H5Tclose(dtype); \ 00147 delete[] dims; \ 00148 if (status<0) \ 00149 { \ 00150 delete[] matrix; \ 00151 SG_ERROR("Error reading dataset\n"); \ 00152 } \ 00153 } 00154 00155 GET_MATRIX(get_bool_matrix, bool, (CT_MATRIX, ST_NONE, PT_BOOL)) 00156 GET_MATRIX(get_char_matrix, char, (CT_MATRIX, ST_NONE, PT_CHAR)) 00157 GET_MATRIX(get_byte_matrix, uint8_t, (CT_MATRIX, ST_NONE, PT_UINT8)) 00158 GET_MATRIX(get_int_matrix, int32_t, (CT_MATRIX, ST_NONE, PT_INT32)) 00159 GET_MATRIX(get_uint_matrix, uint32_t, (CT_MATRIX, ST_NONE, PT_INT32)) 00160 GET_MATRIX(get_long_matrix, int64_t, (CT_MATRIX, ST_NONE, PT_INT64)) 00161 GET_MATRIX(get_ulong_matrix, uint64_t, (CT_MATRIX, ST_NONE, PT_INT64)) 00162 GET_MATRIX(get_short_matrix, int16_t, (CT_MATRIX, ST_NONE, PT_INT16)) 00163 GET_MATRIX(get_word_matrix, uint16_t, (CT_MATRIX, ST_NONE, PT_INT16)) 00164 GET_MATRIX(get_shortreal_matrix, float32_t, (CT_MATRIX, ST_NONE, PT_FLOAT32)) 00165 GET_MATRIX(get_real_matrix, float64_t, (CT_MATRIX, ST_NONE, PT_FLOAT64)) 00166 GET_MATRIX(get_longreal_matrix, floatmax_t, (CT_MATRIX, ST_NONE, PT_FLOATMAX)) 00167 #undef GET_MATRIX 00168 00169 void CHDF5File::get_byte_ndarray(uint8_t*& array, int32_t*& dims, int32_t& num_dims) 00170 { 00171 } 00172 00173 void CHDF5File::get_char_ndarray(char*& array, int32_t*& dims, int32_t& num_dims) 00174 { 00175 } 00176 00177 void CHDF5File::get_int_ndarray(int32_t*& array, int32_t*& dims, int32_t& num_dims) 00178 { 00179 } 00180 00181 void CHDF5File::get_shortreal_ndarray(float32_t*& array, int32_t*& dims, int32_t& num_dims) 00182 { 00183 } 00184 00185 void CHDF5File::get_real_ndarray(float64_t*& array, int32_t*& dims, int32_t& num_dims) 00186 { 00187 } 00188 00189 void CHDF5File::get_short_ndarray(int16_t*& array, int32_t*& dims, int32_t& num_dims) 00190 { 00191 } 00192 00193 void CHDF5File::get_word_ndarray(uint16_t*& array, int32_t*& dims, int32_t& num_dims) 00194 { 00195 } 00196 00197 #define GET_SPARSEMATRIX(fname, sg_type, datatype) \ 00198 void CHDF5File::fname(TSparse<sg_type>*& matrix, int32_t& num_feat, int32_t& num_vec) \ 00199 { \ 00200 if (!(file)) \ 00201 SG_ERROR("File invalid.\n"); \ 00202 } 00203 GET_SPARSEMATRIX(get_bool_sparsematrix, bool, DT_SPARSE_BOOL) 00204 GET_SPARSEMATRIX(get_char_sparsematrix, char, DT_SPARSE_CHAR) 00205 GET_SPARSEMATRIX(get_byte_sparsematrix, uint8_t, DT_SPARSE_BYTE) 00206 GET_SPARSEMATRIX(get_int_sparsematrix, int32_t, DT_SPARSE_INT) 00207 GET_SPARSEMATRIX(get_uint_sparsematrix, uint32_t, DT_SPARSE_UINT) 00208 GET_SPARSEMATRIX(get_long_sparsematrix, int64_t, DT_SPARSE_LONG) 00209 GET_SPARSEMATRIX(get_ulong_sparsematrix, uint64_t, DT_SPARSE_ULONG) 00210 GET_SPARSEMATRIX(get_short_sparsematrix, int16_t, DT_SPARSE_SHORT) 00211 GET_SPARSEMATRIX(get_word_sparsematrix, uint16_t, DT_SPARSE_WORD) 00212 GET_SPARSEMATRIX(get_shortreal_sparsematrix, float32_t, DT_SPARSE_SHORTREAL) 00213 GET_SPARSEMATRIX(get_real_sparsematrix, float64_t, DT_SPARSE_REAL) 00214 GET_SPARSEMATRIX(get_longreal_sparsematrix, floatmax_t, DT_SPARSE_LONGREAL) 00215 #undef GET_SPARSEMATRIX 00216 00217 00218 #define GET_STRING_LIST(fname, sg_type, datatype) \ 00219 void CHDF5File::fname(TString<sg_type>*& strings, int32_t& num_str, int32_t& max_string_len) \ 00220 { \ 00221 } 00222 00223 GET_STRING_LIST(get_bool_string_list, bool, DT_STRING_BOOL) 00224 GET_STRING_LIST(get_char_string_list, char, DT_STRING_CHAR) 00225 GET_STRING_LIST(get_byte_string_list, uint8_t, DT_STRING_BYTE) 00226 GET_STRING_LIST(get_int_string_list, int32_t, DT_STRING_INT) 00227 GET_STRING_LIST(get_uint_string_list, uint32_t, DT_STRING_UINT) 00228 GET_STRING_LIST(get_long_string_list, int64_t, DT_STRING_LONG) 00229 GET_STRING_LIST(get_ulong_string_list, uint64_t, DT_STRING_ULONG) 00230 GET_STRING_LIST(get_short_string_list, int16_t, DT_STRING_SHORT) 00231 GET_STRING_LIST(get_word_string_list, uint16_t, DT_STRING_WORD) 00232 GET_STRING_LIST(get_shortreal_string_list, float32_t, DT_STRING_SHORTREAL) 00233 GET_STRING_LIST(get_real_string_list, float64_t, DT_STRING_REAL) 00234 GET_STRING_LIST(get_longreal_string_list, floatmax_t, DT_STRING_LONGREAL) 00235 #undef GET_STRING_LIST 00236 00239 #define SET_VECTOR(fname, sg_type, dtype, h5type) \ 00240 void CHDF5File::fname(const sg_type* vec, int32_t len) \ 00241 { \ 00242 if (h5file<0 || !vec) \ 00243 SG_ERROR("File or vector invalid.\n"); \ 00244 \ 00245 create_group_hierarchy(); \ 00246 \ 00247 hsize_t dims=(hsize_t) len; \ 00248 hid_t dataspace, dataset, status; \ 00249 dataspace=H5Screate_simple(1, &dims, NULL); \ 00250 if (dataspace<0) \ 00251 SG_ERROR("Could not create hdf5 dataspace\n"); \ 00252 dataset=H5Dcreate(h5file, variable_name, h5type, dataspace, H5P_DEFAULT); \ 00253 if (dataset<0) \ 00254 { \ 00255 SG_ERROR("Could not create hdf5 dataset - does" \ 00256 " dataset '%s' already exist?\n", variable_name); \ 00257 } \ 00258 status=H5Dwrite(dataset, h5type, H5S_ALL, H5S_ALL, H5P_DEFAULT, vec); \ 00259 if (status<0) \ 00260 SG_ERROR("Failed to write hdf5 dataset\n"); \ 00261 H5Dclose(dataset); \ 00262 H5Sclose(dataspace); \ 00263 } 00264 SET_VECTOR(set_bool_vector, bool, DT_VECTOR_BOOL, boolean_type) 00265 SET_VECTOR(set_byte_vector, uint8_t, DT_VECTOR_BYTE, H5T_NATIVE_UINT8) 00266 SET_VECTOR(set_char_vector, char, DT_VECTOR_CHAR, H5T_NATIVE_CHAR) 00267 SET_VECTOR(set_int_vector, int32_t, DT_VECTOR_INT, H5T_NATIVE_INT32) 00268 SET_VECTOR(set_shortreal_vector, float32_t, DT_VECTOR_SHORTREAL, H5T_NATIVE_FLOAT) 00269 SET_VECTOR(set_real_vector, float64_t, DT_VECTOR_REAL, H5T_NATIVE_DOUBLE) 00270 SET_VECTOR(set_short_vector, int16_t, DT_VECTOR_SHORT, H5T_NATIVE_INT16) 00271 SET_VECTOR(set_word_vector, uint16_t, DT_VECTOR_WORD, H5T_NATIVE_UINT16) 00272 #undef SET_VECTOR 00273 00274 #define SET_MATRIX(fname, sg_type, dtype, h5type) \ 00275 void CHDF5File::fname(const sg_type* matrix, int32_t num_feat, int32_t num_vec) \ 00276 { \ 00277 if (h5file<0 || !matrix) \ 00278 SG_ERROR("File or matrix invalid.\n"); \ 00279 \ 00280 create_group_hierarchy(); \ 00281 \ 00282 hsize_t dims[2]={(hsize_t) num_feat, (hsize_t) num_vec}; \ 00283 hid_t dataspace, dataset, status; \ 00284 dataspace=H5Screate_simple(2, dims, NULL); \ 00285 if (dataspace<0) \ 00286 SG_ERROR("Could not create hdf5 dataspace\n"); \ 00287 dataset=H5Dcreate(h5file, variable_name, h5type, dataspace, H5P_DEFAULT); \ 00288 if (dataset<0) \ 00289 { \ 00290 SG_ERROR("Could not create hdf5 dataset - does" \ 00291 " dataset '%s' already exist?\n", variable_name); \ 00292 } \ 00293 status=H5Dwrite(dataset, h5type, H5S_ALL, H5S_ALL, H5P_DEFAULT, matrix); \ 00294 if (status<0) \ 00295 SG_ERROR("Failed to write hdf5 dataset\n"); \ 00296 H5Dclose(dataset); \ 00297 H5Sclose(dataspace); \ 00298 } 00299 SET_MATRIX(set_bool_matrix, bool, DT_DENSE_BOOL, boolean_type) 00300 SET_MATRIX(set_char_matrix, char, DT_DENSE_CHAR, H5T_NATIVE_CHAR) 00301 SET_MATRIX(set_byte_matrix, uint8_t, DT_DENSE_BYTE, H5T_NATIVE_UINT8) 00302 SET_MATRIX(set_int_matrix, int32_t, DT_DENSE_INT, H5T_NATIVE_INT32) 00303 SET_MATRIX(set_uint_matrix, uint32_t, DT_DENSE_UINT, H5T_NATIVE_UINT32) 00304 SET_MATRIX(set_long_matrix, int64_t, DT_DENSE_LONG, H5T_NATIVE_INT64) 00305 SET_MATRIX(set_ulong_matrix, uint64_t, DT_DENSE_ULONG, H5T_NATIVE_UINT64) 00306 SET_MATRIX(set_short_matrix, int16_t, DT_DENSE_SHORT, H5T_NATIVE_INT16) 00307 SET_MATRIX(set_word_matrix, uint16_t, DT_DENSE_WORD, H5T_NATIVE_UINT16) 00308 SET_MATRIX(set_shortreal_matrix, float32_t, DT_DENSE_SHORTREAL, H5T_NATIVE_FLOAT) 00309 SET_MATRIX(set_real_matrix, float64_t, DT_DENSE_REAL, H5T_NATIVE_DOUBLE) 00310 SET_MATRIX(set_longreal_matrix, floatmax_t, DT_DENSE_LONGREAL, H5T_NATIVE_LDOUBLE) 00311 #undef SET_MATRIX 00312 00313 #define SET_SPARSEMATRIX(fname, sg_type, dtype) \ 00314 void CHDF5File::fname(const TSparse<sg_type>* matrix, \ 00315 int32_t num_feat, int32_t num_vec) \ 00316 { \ 00317 if (!(file && matrix)) \ 00318 SG_ERROR("File or matrix invalid.\n"); \ 00319 \ 00320 } 00321 SET_SPARSEMATRIX(set_bool_sparsematrix, bool, DT_SPARSE_BOOL) 00322 SET_SPARSEMATRIX(set_char_sparsematrix, char, DT_SPARSE_CHAR) 00323 SET_SPARSEMATRIX(set_byte_sparsematrix, uint8_t, DT_SPARSE_BYTE) 00324 SET_SPARSEMATRIX(set_int_sparsematrix, int32_t, DT_SPARSE_INT) 00325 SET_SPARSEMATRIX(set_uint_sparsematrix, uint32_t, DT_SPARSE_UINT) 00326 SET_SPARSEMATRIX(set_long_sparsematrix, int64_t, DT_SPARSE_LONG) 00327 SET_SPARSEMATRIX(set_ulong_sparsematrix, uint64_t, DT_SPARSE_ULONG) 00328 SET_SPARSEMATRIX(set_short_sparsematrix, int16_t, DT_SPARSE_SHORT) 00329 SET_SPARSEMATRIX(set_word_sparsematrix, uint16_t, DT_SPARSE_WORD) 00330 SET_SPARSEMATRIX(set_shortreal_sparsematrix, float32_t, DT_SPARSE_SHORTREAL) 00331 SET_SPARSEMATRIX(set_real_sparsematrix, float64_t, DT_SPARSE_REAL) 00332 SET_SPARSEMATRIX(set_longreal_sparsematrix, floatmax_t, DT_SPARSE_LONGREAL) 00333 #undef SET_SPARSEMATRIX 00334 00335 #define SET_STRING_LIST(fname, sg_type, dtype) \ 00336 void CHDF5File::fname(const TString<sg_type>* strings, int32_t num_str) \ 00337 { \ 00338 if (!(file && strings)) \ 00339 SG_ERROR("File or strings invalid.\n"); \ 00340 \ 00341 } 00342 SET_STRING_LIST(set_bool_string_list, bool, DT_STRING_BOOL) 00343 SET_STRING_LIST(set_char_string_list, char, DT_STRING_CHAR) 00344 SET_STRING_LIST(set_byte_string_list, uint8_t, DT_STRING_BYTE) 00345 SET_STRING_LIST(set_int_string_list, int32_t, DT_STRING_INT) 00346 SET_STRING_LIST(set_uint_string_list, uint32_t, DT_STRING_UINT) 00347 SET_STRING_LIST(set_long_string_list, int64_t, DT_STRING_LONG) 00348 SET_STRING_LIST(set_ulong_string_list, uint64_t, DT_STRING_ULONG) 00349 SET_STRING_LIST(set_short_string_list, int16_t, DT_STRING_SHORT) 00350 SET_STRING_LIST(set_word_string_list, uint16_t, DT_STRING_WORD) 00351 SET_STRING_LIST(set_shortreal_string_list, float32_t, DT_STRING_SHORTREAL) 00352 SET_STRING_LIST(set_real_string_list, float64_t, DT_STRING_REAL) 00353 SET_STRING_LIST(set_longreal_string_list, floatmax_t, DT_STRING_LONGREAL) 00354 #undef SET_STRING_LIST 00355 00356 void CHDF5File::get_boolean_type() 00357 { 00358 boolean_type=H5T_NATIVE_UCHAR; 00359 switch (sizeof(bool)) 00360 { 00361 case 1: 00362 boolean_type = H5T_NATIVE_UCHAR; 00363 break; 00364 case 2: 00365 boolean_type = H5T_NATIVE_UINT16; 00366 break; 00367 case 4: 00368 boolean_type = H5T_NATIVE_UINT32; 00369 break; 00370 case 8: 00371 boolean_type = H5T_NATIVE_UINT64; 00372 break; 00373 default: 00374 SG_ERROR("Boolean type not supported on this platform\n"); 00375 } 00376 } 00377 00378 hid_t CHDF5File::get_compatible_type(H5T_class_t t_class, 00379 const TSGDataType* datatype) 00380 { 00381 switch (t_class) 00382 { 00383 case H5T_FLOAT: 00384 case H5T_INTEGER: 00385 switch (datatype->m_ptype) 00386 { 00387 case PT_BOOL: return boolean_type; 00388 case PT_CHAR: return H5T_NATIVE_CHAR; 00389 case PT_INT8: return H5T_NATIVE_INT8; 00390 case PT_UINT8: return H5T_NATIVE_UINT8; 00391 case PT_INT16: return H5T_NATIVE_INT16; 00392 case PT_UINT16: return H5T_NATIVE_UINT16; 00393 case PT_INT32: return H5T_NATIVE_INT32; 00394 case PT_UINT32: return H5T_NATIVE_UINT32; 00395 case PT_INT64: return H5T_NATIVE_INT64; 00396 case PT_UINT64: return H5T_NATIVE_UINT64; 00397 case PT_FLOAT32: return H5T_NATIVE_FLOAT; 00398 case PT_FLOAT64: return H5T_NATIVE_DOUBLE; 00399 case PT_FLOATMAX: return H5T_NATIVE_LDOUBLE; 00400 case PT_SGOBJECT: 00401 SG_ERROR("Implementation error during writing " 00402 "HDF5File!"); 00403 return -1; 00404 } 00405 case H5T_STRING: 00406 SG_ERROR("Strings not supported"); 00407 return -1; 00408 case H5T_VLEN: 00409 SG_ERROR("Variable length containers currently not supported"); 00410 return -1; 00411 case H5T_ARRAY: 00412 SG_ERROR("Array containers currently not supported"); 00413 return -1; 00414 default: 00415 SG_ERROR("Datatype mismatchn"); 00416 return -1; 00417 } 00418 } 00419 00420 void CHDF5File::get_dims(hid_t dataset, int32_t*& dims, int32_t& ndims, int64_t& total_elements) 00421 { 00422 hid_t dataspace = H5Dget_space(dataset); 00423 if (dataspace<0) 00424 SG_ERROR("Error obtaining hdf5 dataspace\n"); 00425 00426 ndims = H5Sget_simple_extent_ndims(dataspace); 00427 total_elements=H5Sget_simple_extent_npoints(dataspace); 00428 hsize_t* dims_out=new hsize_t[ndims]; 00429 dims=new int32_t[ndims]; 00430 H5Sget_simple_extent_dims(dataspace, dims_out, NULL); 00431 for (int32_t i=0; i<ndims; i++) 00432 dims[i]=dims_out[i]; 00433 delete[] dims_out; 00434 H5Sclose(dataspace); 00435 } 00436 00437 void CHDF5File::create_group_hierarchy() 00438 { 00439 char* vname=strdup(variable_name); 00440 int32_t vlen=strlen(vname); 00441 for (int32_t i=0; i<vlen; i++) 00442 { 00443 if (i!=0 && vname[i]=='/') 00444 { 00445 vname[i]='\0'; 00446 hid_t g = H5Gopen(h5file, vname); 00447 if (g<0) 00448 { 00449 g=H5Gcreate(h5file, vname, 0); 00450 if (g<0) 00451 SG_ERROR("Error creating group '%s'\n", vname); 00452 vname[i]='/'; 00453 } 00454 H5Gclose(g); 00455 } 00456 } 00457 free(vname); 00458 } 00459 #endif // HDF5