16 #include <H5Tpublic.h>
17 #include <H5Dpublic.h>
18 #include <H5Gpublic.h>
19 #include <H5Spublic.h>
20 #include <H5Ppublic.h>
30 hid_t root_id, set_id;
36 #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
54 #if defined( H5Gopen_vers ) && H5Gopen_vers > 1
96 if( *have_parent < 0 )
119 dims[0] = (hsize_t)num_sets;
120 dims[1] = (hsize_t)4;
122 if( table_id < 0 )
return -1;
124 first_id = file_ptr->
max_id + 1;
127 H5Dclose( table_id );
131 *first_id_out = first_id;
132 file_ptr->
max_id += num_sets;
135 H5Dclose( table_id );
155 if( table_id < 0 )
return -1;
160 if( dims[1] != 4 && dims[1] != 3 )
162 mhdf_setFail( status,
"Invalid format for meshset table.\n" );
163 H5Dclose( table_id );
183 if( table_id < 0 )
return -1;
200 hid_t slab_id, sslab_id, smem_id, mem_id;
201 hsize_t offsets[2], counts[2], mcounts[2], moffsets[2] = { 0, 0 };
204 const int fill_val = -1;
205 const hsize_t one = 1;
209 if( offset < 0 || count < 0 )
212 "Invalid input for %s: "
213 "offset = %ld, count = %ld\n",
214 read ?
"read" :
"write", offset, count );
218 slab_id = H5Dget_space( table_id );
221 mhdf_setFail( status,
"Internal error calling H5Dget_space." );
225 dims = H5Sget_simple_extent_ndims( slab_id );
229 mhdf_setFail( status,
"Internal error: unexpected dataset rank: %d.", dims );
233 dims = H5Sget_simple_extent_dims( slab_id, counts, NULL );
237 mhdf_setFail( status,
"Internal error calling H5Sget_simple_extend_dims." );
241 if( (
unsigned long)( offset + count ) > counts[0] )
244 mhdf_setFail( status,
"Requested %s of rows %ld to %ld of a %ld row table.\n", read ?
"read" :
"write", offset,
245 offset + count - 1, (
long)counts[dims - 1] );
248 counts[0] = (hsize_t)count;
249 offsets[0] = (hsize_t)offset;
252 mem_id = H5Screate_simple( dims, mcounts, NULL );
255 mem_id = H5Screate_simple( 1, &one, NULL );
256 if( mem_id && 0 > H5Sselect_none( mem_id ) )
264 mhdf_setFail( status,
"Internal error calling H5Screate_simple." );
273 rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
275 rval = H5Sselect_none( slab_id );
280 mhdf_setFail( status,
"Internal error calling H5Sselect_hyperslab." );
285 rval = H5Dread( table_id, type, mem_id, slab_id, prop, data );
287 rval = H5Dwrite( table_id, type, mem_id, slab_id, prop, data );
290 else if( counts[1] == 3 )
293 for( i = 0; i < 3 && rval >= 0; ++i )
295 smem_id = H5Scopy( mem_id );
296 sslab_id = H5Scopy( slab_id );
297 if( smem_id < 0 || sslab_id < 0 )
299 if( smem_id >= 0 ) H5Sclose( smem_id );
300 mhdf_setFail( status,
"Internal error calling H5Scopy." );
307 rval = H5Sselect_hyperslab( sslab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
309 rval = H5Sselect_none( sslab_id );
314 mhdf_setFail( status,
"Internal error calling H5Sselect_hyperslab." );
319 moffsets[1] = ( i == 2 ) ? 3 : i;
320 rval = H5Sselect_hyperslab( smem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL );
323 H5Sclose( sslab_id );
326 mhdf_setFail( status,
"Internal error calling H5Sselect_hyperslab." );
331 rval = H5Dread( table_id, type, smem_id, sslab_id, prop, data );
333 rval = H5Dwrite( table_id, type, smem_id, sslab_id, prop, data );
335 H5Sclose( sslab_id );
339 if( read && rval >= 0 )
343 H5Sselect_hyperslab( mem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL );
344 rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id );
351 mhdf_setFail( status,
"Invalid dimension for meshset metadata table." );
359 mhdf_setFail( status,
"Internal error calling H5D%s.", read ?
"read" :
"write" );
422 hid_t slab_id, mem_id;
423 hsize_t offsets[2], counts[2], mcount = count;
426 const int fill_val = -1;
428 if( offset < 0 || count < 0 )
431 "Invalid input for reading set description column: "
432 "offset = %ld, count = %ld\n",
439 slab_id = H5Dget_space( table_id );
442 mhdf_setFail( status,
"Internal error calling H5Dget_space." );
446 dims = H5Sget_simple_extent_ndims( slab_id );
450 mhdf_setFail( status,
"Internal error: unexpected dataset rank: %d.", dims );
454 dims = H5Sget_simple_extent_dims( slab_id, counts, NULL );
458 mhdf_setFail( status,
"Internal error calling H5Sget_simple_extend_dims." );
462 if( (
unsigned long)( offset + count ) > counts[0] )
465 mhdf_setFail( status,
"Requested read of rows %ld to %ld of a %ld row table.\n", offset, offset + count - 1,
472 mem_id = H5Screate_simple( 1, &mcount, NULL );
476 mhdf_setFail( status,
"Internal error calling H5Screate_simple." );
491 rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id );
496 mhdf_setFail( status,
"Internal error calling H5Dfill" );
505 else if( column ==
FLAGS )
508 else if( counts[1] != 4 )
512 mhdf_setFail( status,
"Invalid dimension for meshset metadata table." );
519 offsets[0] = (hsize_t)offset;
520 counts[0] = (hsize_t)count;
523 rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL );
525 rval = H5Sselect_none( slab_id );
530 mhdf_setFail( status,
"Internal error calling H5Sselect_hyperslab." );
536 rval = H5Dread( table_id, type, mem_id, slab_id, prop, data );
541 mhdf_setFail( status,
"Internal error calling H5Dread." );
639 hsize_t
dim = (hsize_t)data_list_size;
645 if( data_list_size < 1 )
667 if( !data_list_size_out )
675 *data_list_size_out = (long)
dim;
683 mhdf_write_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
702 mhdf_read_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
714 mhdf_read_data( table_id, offset, count, type, data, prop, status );
722 hsize_t
dim = (hsize_t)child_list_size;
728 if( child_list_size < 1 )
750 if( !child_list_size )
758 *child_list_size = (long)
dim;
767 hsize_t
dim = (hsize_t)parent_list_size;
773 if( parent_list_size < 1 )
795 if( !parent_list_size )
803 *parent_list_size = (long)
dim;
816 mhdf_write_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
835 mhdf_read_data( table_id, offset, count, type, data, H5P_DEFAULT, status );
847 mhdf_read_data( table_id, offset, count, type, data, prop, status );