comparison src/ov-fcn-inline.cc @ 9892:ac69e6f4b33d

Add HDF5-1.8 compatibility while maintaining compatibility with HDF5-1.6 versions
author Kacper Kowalik <xarthisius.kk@gmail.com>
date Tue, 01 Dec 2009 00:49:07 +0100
parents b3089dba88bf
children cd96d29c5efa
comparison
equal deleted inserted replaced
9891:1506a17832c9 9892:ac69e6f4b33d
271 bool 271 bool
272 octave_fcn_inline::save_hdf5 (hid_t loc_id, const char *name, 272 octave_fcn_inline::save_hdf5 (hid_t loc_id, const char *name,
273 bool /* save_as_floats */) 273 bool /* save_as_floats */)
274 { 274 {
275 hid_t group_hid = -1; 275 hid_t group_hid = -1;
276 #if HAVE_HDF5_18
277 group_hid = H5Gcreate (loc_id, name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
278 #else
276 group_hid = H5Gcreate (loc_id, name, 0); 279 group_hid = H5Gcreate (loc_id, name, 0);
280 #endif
277 if (group_hid < 0 ) return false; 281 if (group_hid < 0 ) return false;
278 282
279 size_t len = 0; 283 size_t len = 0;
280 for (int i = 0; i < ifargs.length (); i++) 284 for (int i = 0; i < ifargs.length (); i++)
281 if (len < ifargs(i).length ()) 285 if (len < ifargs(i).length ())
297 if (space_hid < 0) 301 if (space_hid < 0)
298 { 302 {
299 H5Gclose (group_hid); 303 H5Gclose (group_hid);
300 return false; 304 return false;
301 } 305 }
302 306 #if HAVE_HDF5_18
307 data_hid = H5Dcreate (group_hid, "args", H5T_NATIVE_CHAR, space_hid,
308 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
309 #else
303 data_hid = H5Dcreate (group_hid, "args", H5T_NATIVE_CHAR, space_hid, 310 data_hid = H5Dcreate (group_hid, "args", H5T_NATIVE_CHAR, space_hid,
304 H5P_DEFAULT); 311 H5P_DEFAULT);
312 #endif
305 if (data_hid < 0) 313 if (data_hid < 0)
306 { 314 {
307 H5Sclose (space_hid); 315 H5Sclose (space_hid);
308 H5Gclose (group_hid); 316 H5Gclose (group_hid);
309 return false; 317 return false;
347 { 355 {
348 H5Tclose (type_hid); 356 H5Tclose (type_hid);
349 H5Gclose (group_hid); 357 H5Gclose (group_hid);
350 return false; 358 return false;
351 } 359 }
352 360 #if HAVE_HDF5_18
361 data_hid = H5Dcreate (group_hid, "nm", type_hid, space_hid,
362 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
363 #else
353 data_hid = H5Dcreate (group_hid, "nm", type_hid, space_hid, H5P_DEFAULT); 364 data_hid = H5Dcreate (group_hid, "nm", type_hid, space_hid, H5P_DEFAULT);
365 #endif
354 if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, 366 if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL,
355 H5P_DEFAULT, nm.c_str ()) < 0) 367 H5P_DEFAULT, nm.c_str ()) < 0)
356 { 368 {
357 H5Sclose (space_hid); 369 H5Sclose (space_hid);
358 H5Tclose (type_hid); 370 H5Tclose (type_hid);
367 { 379 {
368 H5Gclose (group_hid); 380 H5Gclose (group_hid);
369 return false; 381 return false;
370 } 382 }
371 383
384 #if HAVE_HDF5_18
385 data_hid = H5Dcreate (group_hid, "iftext", type_hid, space_hid,
386 H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
387 #else
372 data_hid = H5Dcreate (group_hid, "iftext", type_hid, space_hid, 388 data_hid = H5Dcreate (group_hid, "iftext", type_hid, space_hid,
373 H5P_DEFAULT); 389 H5P_DEFAULT);
390 #endif
374 if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, 391 if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL,
375 H5P_DEFAULT, iftext.c_str ()) < 0) 392 H5P_DEFAULT, iftext.c_str ()) < 0)
376 { 393 {
377 H5Sclose (space_hid); 394 H5Sclose (space_hid);
378 H5Tclose (type_hid); 395 H5Tclose (type_hid);
393 { 410 {
394 hid_t group_hid, data_hid, space_hid, type_hid, type_class_hid, st_id; 411 hid_t group_hid, data_hid, space_hid, type_hid, type_class_hid, st_id;
395 hsize_t rank; 412 hsize_t rank;
396 int slen; 413 int slen;
397 414
415 #if HAVE_HDF5_18
416 group_hid = H5Gopen (loc_id, name, H5P_DEFAULT);
417 #else
398 group_hid = H5Gopen (loc_id, name); 418 group_hid = H5Gopen (loc_id, name);
419 #endif
399 if (group_hid < 0 ) return false; 420 if (group_hid < 0 ) return false;
400 421
422 #if HAVE_HDF5_18
423 data_hid = H5Dopen (group_hid, "args", H5P_DEFAULT);
424 #else
401 data_hid = H5Dopen (group_hid, "args"); 425 data_hid = H5Dopen (group_hid, "args");
426 #endif
402 space_hid = H5Dget_space (data_hid); 427 space_hid = H5Dget_space (data_hid);
403 rank = H5Sget_simple_extent_ndims (space_hid); 428 rank = H5Sget_simple_extent_ndims (space_hid);
404 429
405 if (rank != 2) 430 if (rank != 2)
406 { 431 {
432 H5Sclose (space_hid); 457 H5Sclose (space_hid);
433 458
434 for (size_t i = 0; i < hdims[1]; i++) 459 for (size_t i = 0; i < hdims[1]; i++)
435 ifargs(i) = std::string (s1 + i*hdims[0]); 460 ifargs(i) = std::string (s1 + i*hdims[0]);
436 461
462 #if HAVE_HDF5_18
463 data_hid = H5Dopen (group_hid, "nm", H5P_DEFAULT);
464 #else
437 data_hid = H5Dopen (group_hid, "nm"); 465 data_hid = H5Dopen (group_hid, "nm");
466 #endif
438 467
439 if (data_hid < 0) 468 if (data_hid < 0)
440 { 469 {
441 H5Gclose (group_hid); 470 H5Gclose (group_hid);
442 return false; 471 return false;
490 } 519 }
491 H5Tclose (st_id); 520 H5Tclose (st_id);
492 H5Dclose (data_hid); 521 H5Dclose (data_hid);
493 nm = nm_tmp; 522 nm = nm_tmp;
494 523
524 #if HAVE_HDF5_18
525 data_hid = H5Dopen (group_hid, "iftext", H5P_DEFAULT);
526 #else
495 data_hid = H5Dopen (group_hid, "iftext"); 527 data_hid = H5Dopen (group_hid, "iftext");
528 #endif
496 529
497 if (data_hid < 0) 530 if (data_hid < 0)
498 { 531 {
499 H5Gclose (group_hid); 532 H5Gclose (group_hid);
500 return false; 533 return false;