MOAB: Mesh Oriented datABase
(version 5.4.1)
|
#include <H5Tpublic.h>
#include <H5Dpublic.h>
#include <H5Gpublic.h>
#include <H5Spublic.h>
#include <H5Ppublic.h>
#include "mhdf.h"
#include "util.h"
#include "file-handle.h"
#include "status.h"
#include "names-and-paths.h"
Go to the source code of this file.
Enumerations | |
enum | SetMetaCol { CONTENT = 0, CHILDREN = 1, PARENTS = 2, FLAGS = 3 } |
Functions | |
int | mhdf_haveSets (mhdf_FileHandle file, int *have_data, int *have_child, int *have_parent, mhdf_Status *status) |
Check if file contains any sets. | |
hid_t | mhdf_createSetMeta (mhdf_FileHandle file, long num_sets, long *first_id_out, mhdf_Status *status) |
Create table holding list of meshsets and their properties. | |
hid_t | mhdf_openSetMeta (mhdf_FileHandle file, long *num_sets, long *first_id_out, mhdf_Status *status) |
Open table holding list of meshsets and their properties. | |
hid_t | mhdf_openSetMetaSimple (mhdf_FileHandle file, mhdf_Status *status) |
static int | mhdf_readwriteSetMeta (hid_t table_id, int read, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetMeta (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read list of sets and meta-information about sets. | |
void | mhdf_readSetMetaWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_writeSetMeta (hid_t table_id, long offset, long count, hid_t type, const void *data, mhdf_Status *status) |
Write list of sets and meta-information about sets. | |
void | mhdf_writeSetMetaWithOpt (hid_t table_id, long offset, long count, hid_t type, const void *data, hid_t prop, mhdf_Status *status) |
static int | mhdf_readSetMetaColumn (hid_t table_id, enum SetMetaCol column, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetFlags (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read only the flags portion of the set description table. | |
void | mhdf_readSetFlagsWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetContentEndIndices (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read only the content end indices portion of the set description table. | |
void | mhdf_readSetContentEndIndicesWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetChildEndIndices (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read only the child end indices portion of the set description table. | |
void | mhdf_readSetChildEndIndicesWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetParentEndIndices (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read only the parent end indices portion of the set description table. | |
void | mhdf_readSetParentEndIndicesWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
hid_t | mhdf_createSetData (mhdf_FileHandle file_handle, long data_list_size, mhdf_Status *status) |
Create file object to hold list of meshset contents. | |
hid_t | mhdf_openSetData (mhdf_FileHandle file_handle, long *data_list_size_out, mhdf_Status *status) |
Open the file object for the meshset contents. | |
void | mhdf_writeSetData (hid_t table_id, long offset, long count, hid_t type, const void *data, mhdf_Status *status) |
Write set contents. | |
void | mhdf_writeSetDataWithOpt (hid_t table_id, long offset, long count, hid_t type, const void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetData (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read set contents. | |
void | mhdf_readSetDataWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
hid_t | mhdf_createSetChildren (mhdf_FileHandle file_handle, long child_list_size, mhdf_Status *status) |
Create file object for storing the set child list. | |
hid_t | mhdf_openSetChildren (mhdf_FileHandle file_handle, long *child_list_size, mhdf_Status *status) |
Open the file object containing the set child list. | |
hid_t | mhdf_createSetParents (mhdf_FileHandle file_handle, long parent_list_size, mhdf_Status *status) |
Create file object for storing the set parent list. | |
hid_t | mhdf_openSetParents (mhdf_FileHandle file_handle, long *parent_list_size, mhdf_Status *status) |
Open the file object containing the set parent list. | |
void | mhdf_writeSetParentsChildren (hid_t table_id, long offset, long count, hid_t type, const void *data, mhdf_Status *status) |
Write set parent/child list. | |
void | mhdf_writeSetParentsChildrenWithOpt (hid_t table_id, long offset, long count, hid_t type, const void *data, hid_t prop, mhdf_Status *status) |
void | mhdf_readSetParentsChildren (hid_t table_id, long offset, long count, hid_t type, void *data, mhdf_Status *status) |
Read set parent/child list. | |
void | mhdf_readSetParentsChildrenWithOpt (hid_t table_id, long offset, long count, hid_t type, void *data, hid_t prop, mhdf_Status *status) |
enum SetMetaCol |
static int mhdf_readSetMetaColumn | ( | hid_t | table_id, |
enum SetMetaCol | column, | ||
long | offset, | ||
long | count, | ||
hid_t | type, | ||
void * | data, | ||
hid_t | prop, | ||
mhdf_Status * | status | ||
) | [static] |
Definition at line 413 of file sets.c.
References FLAGS, mhdf_setFail(), mhdf_setOkay(), and PARENTS.
Referenced by mhdf_readSetChildEndIndices(), mhdf_readSetChildEndIndicesWithOpt(), mhdf_readSetContentEndIndices(), mhdf_readSetContentEndIndicesWithOpt(), mhdf_readSetFlags(), mhdf_readSetFlagsWithOpt(), mhdf_readSetParentEndIndices(), and mhdf_readSetParentEndIndicesWithOpt().
{ hid_t slab_id, mem_id; hsize_t offsets[2], counts[2], mcount = count; herr_t rval = 0; int dims; const int fill_val = -1; if( offset < 0 || count < 0 ) { mhdf_setFail( status, "Invalid input for reading set description column: " "offset = %ld, count = %ld\n", offset, count ); return 0; } /* Get dimensions of table, and check against requested count and offset */ slab_id = H5Dget_space( table_id ); if( slab_id < 0 ) { mhdf_setFail( status, "Internal error calling H5Dget_space." ); return 0; } dims = H5Sget_simple_extent_ndims( slab_id ); if( dims != 2 ) { H5Sclose( slab_id ); mhdf_setFail( status, "Internal error: unexpected dataset rank: %d.", dims ); return 0; } dims = H5Sget_simple_extent_dims( slab_id, counts, NULL ); if( dims < 0 ) { H5Sclose( slab_id ); mhdf_setFail( status, "Internal error calling H5Sget_simple_extend_dims." ); return 0; } if( (unsigned long)( offset + count ) > counts[0] ) { H5Sclose( slab_id ); mhdf_setFail( status, "Requested read of rows %ld to %ld of a %ld row table.\n", offset, offset + count - 1, (long)counts[0] ); return 0; } /* Create a slab definition for the block of memory we're reading into */ mem_id = H5Screate_simple( 1, &mcount, NULL ); if( mem_id < 0 ) { H5Sclose( slab_id ); mhdf_setFail( status, "Internal error calling H5Screate_simple." ); return 0; } /* Old, 3-column table. * New table is {contents, children, parents, flags} * Old table is {contents, children, flags} * If asking for parents, just return zeros. * If asking for flags, fix column value. */ offsets[1] = column; if( counts[1] == 3 ) { if( column == PARENTS ) { rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id ); H5Sclose( mem_id ); H5Sclose( slab_id ); if( rval < 0 ) { mhdf_setFail( status, "Internal error calling H5Dfill" ); return 0; } else { mhdf_setOkay( status ); return 1; } } else if( column == FLAGS ) --offsets[1]; } else if( counts[1] != 4 ) { H5Sclose( mem_id ); H5Sclose( slab_id ); mhdf_setFail( status, "Invalid dimension for meshset metadata table." ); return 0; } /* Create a slab defintion for the portion of the table we want to read. */ /* offsets[1] was initialized in the above block of code. */ offsets[0] = (hsize_t)offset; counts[0] = (hsize_t)count; counts[1] = 1; /* one column */ if( count ) rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL ); else rval = H5Sselect_none( slab_id ); if( rval < 0 ) { H5Sclose( mem_id ); H5Sclose( slab_id ); mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." ); return 0; } /* Read the data */ rval = H5Dread( table_id, type, mem_id, slab_id, prop, data ); H5Sclose( mem_id ); H5Sclose( slab_id ); if( rval < 0 ) { mhdf_setFail( status, "Internal error calling H5Dread." ); return 0; } mhdf_setOkay( status ); return 1; }
static int mhdf_readwriteSetMeta | ( | hid_t | table_id, |
int | read, | ||
long | offset, | ||
long | count, | ||
hid_t | type, | ||
void * | data, | ||
hid_t | prop, | ||
mhdf_Status * | status | ||
) | [static] |
Definition at line 191 of file sets.c.
References mhdf_setFail(), and mhdf_setOkay().
Referenced by mhdf_readSetMeta(), mhdf_readSetMetaWithOpt(), mhdf_writeSetMeta(), and mhdf_writeSetMetaWithOpt().
{ hid_t slab_id, sslab_id, smem_id, mem_id; hsize_t offsets[2], counts[2], mcounts[2], moffsets[2] = { 0, 0 }; herr_t rval = 0; int dims, i; const int fill_val = -1; const hsize_t one = 1; mcounts[0] = count; mcounts[1] = 4; if( offset < 0 || count < 0 ) { mhdf_setFail( status, "Invalid input for %s: " "offset = %ld, count = %ld\n", read ? "read" : "write", offset, count ); return 0; } slab_id = H5Dget_space( table_id ); if( slab_id < 0 ) { mhdf_setFail( status, "Internal error calling H5Dget_space." ); return 0; } dims = H5Sget_simple_extent_ndims( slab_id ); if( dims != 2 ) { H5Sclose( slab_id ); mhdf_setFail( status, "Internal error: unexpected dataset rank: %d.", dims ); return 0; } dims = H5Sget_simple_extent_dims( slab_id, counts, NULL ); if( dims < 0 ) { H5Sclose( slab_id ); mhdf_setFail( status, "Internal error calling H5Sget_simple_extend_dims." ); return 0; } if( (unsigned long)( offset + count ) > counts[0] ) { H5Sclose( slab_id ); mhdf_setFail( status, "Requested %s of rows %ld to %ld of a %ld row table.\n", read ? "read" : "write", offset, offset + count - 1, (long)counts[dims - 1] ); return 0; } counts[0] = (hsize_t)count; offsets[0] = (hsize_t)offset; if( count ) mem_id = H5Screate_simple( dims, mcounts, NULL ); else { /* special case for 'NULL' read during collective parallel IO */ mem_id = H5Screate_simple( 1, &one, NULL ); if( mem_id && 0 > H5Sselect_none( mem_id ) ) { H5Sclose( mem_id ); mem_id = -1; } } if( mem_id < 0 ) { mhdf_setFail( status, "Internal error calling H5Screate_simple." ); return 0; } /* Normal table: 4 columns */ if( counts[1] == 4 ) { offsets[1] = 0; if( count ) rval = H5Sselect_hyperslab( slab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL ); else /* special case for 'NULL' read during collective parallel IO */ rval = H5Sselect_none( slab_id ); if( rval < 0 ) { H5Sclose( mem_id ); H5Sclose( slab_id ); mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." ); return 0; } if( read ) rval = H5Dread( table_id, type, mem_id, slab_id, prop, data ); else rval = H5Dwrite( table_id, type, mem_id, slab_id, prop, data ); } /* Old table: 3 columns, no parent link counts */ else if( counts[1] == 3 ) { rval = 0; for( i = 0; i < 3 && rval >= 0; ++i ) { smem_id = H5Scopy( mem_id ); sslab_id = H5Scopy( slab_id ); if( smem_id < 0 || sslab_id < 0 ) { if( smem_id >= 0 ) H5Sclose( smem_id ); mhdf_setFail( status, "Internal error calling H5Scopy." ); return 0; } counts[1] = 1; offsets[1] = i; if( count ) rval = H5Sselect_hyperslab( sslab_id, H5S_SELECT_SET, offsets, NULL, counts, NULL ); else rval = H5Sselect_none( sslab_id ); if( rval < 0 ) { H5Sclose( slab_id ); H5Sclose( mem_id ); mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." ); return 0; } mcounts[1] = 1; moffsets[1] = ( i == 2 ) ? 3 : i; rval = H5Sselect_hyperslab( smem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL ); if( rval < 0 ) { H5Sclose( sslab_id ); H5Sclose( slab_id ); H5Sclose( mem_id ); mhdf_setFail( status, "Internal error calling H5Sselect_hyperslab." ); return 0; } if( read ) rval = H5Dread( table_id, type, smem_id, sslab_id, prop, data ); else rval = H5Dwrite( table_id, type, smem_id, sslab_id, prop, data ); H5Sclose( sslab_id ); H5Sclose( smem_id ); } if( read && rval >= 0 ) { mcounts[1] = 1; moffsets[1] = 2; H5Sselect_hyperslab( mem_id, H5S_SELECT_SET, moffsets, NULL, mcounts, NULL ); rval = H5Dfill( &fill_val, H5T_NATIVE_INT, data, type, mem_id ); } } else { H5Sclose( mem_id ); H5Sclose( slab_id ); mhdf_setFail( status, "Invalid dimension for meshset metadata table." ); return 0; } H5Sclose( slab_id ); H5Sclose( mem_id ); if( rval < 0 ) { mhdf_setFail( status, "Internal error calling H5D%s.", read ? "read" : "write" ); return 0; } mhdf_setOkay( status ); return 1; }