use new macro H5_RETURN_ERROR where possible

This commit is contained in:
2016-07-01 17:59:12 +02:00
parent 7b1079ae5f
commit c80f6f5679
21 changed files with 704 additions and 732 deletions
+28 -35
View File
@@ -38,11 +38,10 @@ h5_add_attachment (
struct stat st;
if (stat (fname, &st) < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot stat file '%s'",
fname));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot stat file '%s'",
fname);
}
hsize_t fsize = st.st_size;
hsize_t write_length;
@@ -52,30 +51,27 @@ h5_add_attachment (
write_length = fsize;
int fd;
if ((fd = open (fname, O_RDONLY)) < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot open file '%s' for reading",
fname));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot open file '%s' for reading",
fname);
}
again:
if (read (fd, buf, fsize) < 0) {
if (errno == EINTR) {
goto again;
} else {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot read file '%s'",
fname));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot read file '%s'",
fname);
}
}
if (close (fd) < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot close file '%s'",
fname));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot close file '%s'",
fname);
}
} else {
@@ -284,25 +280,22 @@ h5_get_attachment (
if (f->myproc == 0) {
int fd;
if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) {
H5_LEAVE (
h5_error (
H5_ERR_H5,
"Error opening file '%s': %s",
fname, strerror(errno)));
H5_RETURN_ERROR (
H5_ERR_H5,
"Error opening file '%s': %s",
fname, strerror(errno));
}
if (write (fd, buf, fsize) != fsize) {
H5_LEAVE (
h5_error (
H5_ERR_H5,
"Error writing to file '%s': %s",
fname, strerror(errno)));
H5_RETURN_ERROR (
H5_ERR_H5,
"Error writing to file '%s': %s",
fname, strerror(errno));
}
if (close (fd) < 0) {
H5_LEAVE (
h5_error (
H5_ERR_H5,
"Error closing file '%s': %s",
fname, strerror(errno)));
H5_RETURN_ERROR (
H5_ERR_H5,
"Error closing file '%s': %s",
fname, strerror(errno));
}
}
TRY (h5_free (buf));
+44 -55
View File
@@ -193,11 +193,10 @@ h5_set_prop_file_mpio_collective (
H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm);
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class);
}
props->flags &= ~(H5_VFD_MPIO_POSIX | H5_VFD_MPIO_INDEPENDENT | H5_VFD_CORE);
props->flags |= H5_VFD_MPIO_COLLECTIVE;
@@ -219,11 +218,10 @@ h5_set_prop_file_mpio_independent (
H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm);
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class);
}
props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE);
props->flags |= H5_VFD_MPIO_INDEPENDENT;
@@ -241,11 +239,10 @@ h5_set_prop_file_mpio_posix (
H5_CORE_API_ENTER (h5_err_t, "props=%p, comm=%p", props, comm);
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class);
}
props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE);
props->flags |= H5_VFD_MPIO_INDEPENDENT;
@@ -263,11 +260,10 @@ h5_set_prop_file_core_vfd (
H5_CORE_API_ENTER (h5_err_t, "props=%p, increment=%lld", props, (long long int)increment);
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class);
}
props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_INDEPENDENT | H5_VFD_MPIO_POSIX);
props->flags |= H5_VFD_MPIO_INDEPENDENT;
@@ -292,11 +288,10 @@ h5_set_prop_file_align (
"props=%p, align=%lld",
props, (long long int)align);
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class);
}
props->align = align;
H5_RETURN (H5_SUCCESS);
@@ -313,11 +308,10 @@ h5_set_prop_file_throttle (
"props=%p, throttle=%lld",
props, (long long int)throttle);
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)props->class);
}
// throttle only if VFD is MPIO independent od POSIX
h5_int64_t mask = H5_VFD_MPIO_INDEPENDENT;
@@ -357,11 +351,10 @@ h5_create_prop (
set_default_file_props ((h5_prop_file_t*)prop);
break;
default:
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)class);
}
H5_RETURN ((h5_prop_t)prop);
}
@@ -379,11 +372,10 @@ h5_close_prop (
break;
}
default:
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)prop->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld",
(long long int)prop->class);
}
H5_RETURN (h5_free (prop));
}
@@ -441,19 +433,17 @@ open_file (
}
}
else {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid file access mode '%lld'.",
(long long int)f->props->flags & 0xff));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid file access mode '%lld'.",
(long long int)f->props->flags & 0xff);
}
if (f->file < 0)
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot open file '%s' with mode '%s'",
filename, H5_O_MODES[f->props->flags & 0xff]));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot open file '%s' with mode '%s'",
filename, H5_O_MODES[f->props->flags & 0xff]);
TRY (f->root_gid = hdf5_open_group (f->file, "/" ));
TRY (h5upriv_open_file (f));
@@ -482,11 +472,10 @@ h5_open_file2 (
if (props != H5_PROP_DEFAULT) {
if (props->class != H5_PROP_FILE) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Invalid property class: %lld.",
(long long int)props->class));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid property class: %lld.",
(long long int)props->class);
}
f->props->comm = props->comm;
f->props->flags = props->flags;
+5 -6
View File
@@ -93,12 +93,11 @@ h5priv_normalize_dataset_name (
}
if ( strcmp( name2, H5BLOCK_GROUPNAME_BLOCK ) == 0 ) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Can't create dataset or field with name '%s'"
" because it is reserved by H5Block.",
H5BLOCK_GROUPNAME_BLOCK));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Can't create dataset or field with name '%s'"
" because it is reserved by H5Block.",
H5BLOCK_GROUPNAME_BLOCK);
}
H5_RETURN (H5_SUCCESS);
}
+17 -19
View File
@@ -215,14 +215,13 @@ _write_data (
hid_t type_file;
TRY( type_file = hdf5_get_dataset_type (dataset) );
if ( type != type_file ) {
H5_LEAVE (
h5_error(
H5_ERR_HDF5,
"Field '%s' already has type '%s' "
"but was written as '%s'.",
field_name,
hdf5_get_type_name (type_file),
hdf5_get_type_name (type)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Field '%s' already has type '%s' "
"but was written as '%s'.",
field_name,
hdf5_get_type_name (type_file),
hdf5_get_type_name (type));
}
} else {
TRY (dataset = hdf5_create_dataset(
@@ -328,21 +327,20 @@ _select_hyperslab_for_reading (
TRY (rank = hdf5_get_dims_of_dataspace(b->diskshape, field_dims, NULL));
if (rank != 3)
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"H5Block dataset has bad rank '%d' instead"
" of rank 3! Is the file corrupt?",
rank));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"H5Block dataset has bad rank '%d' instead"
" of rank 3! Is the file corrupt?",
rank);
if ( (field_dims[0] < (hsize_t)b->k_max) ||
(field_dims[1] < (hsize_t)b->j_max) ||
(field_dims[2] < (hsize_t)b->i_max) )
H5_LEAVE (
h5_error(
H5_ERR_VIEW,
"H5Block dataset has invalid view. "
"Is the file corrupt?"));
H5_RETURN_ERROR (
H5_ERR_VIEW,
"%s",
"H5Block dataset has invalid view. "
"Is the file corrupt?");
h5_debug (
"field_dims: (%lld,%lld,%lld)",
+39 -34
View File
@@ -454,9 +454,10 @@ h5bpriv_open_block_group (
TRY (hdf5_close_group (b->block_gid));
b->block_gid = hdf5_open_group (f->step_gid, H5BLOCK_GROUPNAME_BLOCK);
if (f->b->block_gid < 0)
H5_LEAVE (h5_error(
H5_ERR_INVAL,
"Time step does not contain H5Block data!"));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Time step does not contain H5Block data!");
H5_RETURN (H5_SUCCESS);
}
@@ -761,14 +762,14 @@ h5b_3d_set_grid (
(long long unsigned)j,
(long long unsigned)k);
if (i*j*k != f->nprocs) {
H5_LEAVE (
h5_error(H5_ERR_INVAL,
"Grid dimensions (%lld,%lld,%lld) do not multiply "
"out to %d MPI processors!",
(long long)i,
(long long)j,
(long long)k,
f->nprocs));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Grid dimensions (%lld,%lld,%lld) do not multiply "
"out to %d MPI processors!",
(long long)i,
(long long)j,
(long long)k,
f->nprocs);
}
f->b->k_grid = i;
@@ -798,9 +799,10 @@ h5b_3d_get_grid_coords (
"f=%p, proc=%d, i=%p, j=%p, k=%p",
f, proc, i, j, k);
if ( !f->b->have_grid )
H5_LEAVE (
h5_error(H5_ERR_INVAL,
"Grid dimensions have not been set!"));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Grid dimensions have not been set!");
int coords[3];
TRY( h5priv_mpi_cart_coords(f->b->cart_comm, proc, 3, coords) );
@@ -825,9 +827,10 @@ h5b_3d_set_dims (
(long long unsigned)j,
(long long unsigned)k);
if ( !f->b->have_grid )
H5_LEAVE (
h5_error(H5_ERR_INVAL,
"Grid dimensions have not been set!"));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Grid dimensions have not been set!");
h5_size_t dims[3] = { k, j, i };
h5_size_t check_dims[3] = { k, j, i };
@@ -839,17 +842,17 @@ h5b_3d_set_dims (
dims[1] != check_dims[1] ||
dims[2] != check_dims[2]
) {
H5_LEAVE (
h5_error(H5_ERR_INVAL,
"[%d] Block dimensions do not agree: "
"(%lld,%lld,%lld) != (%lld,%lld,%lld)!",
f->myproc,
(long long)dims[0],
(long long)dims[1],
(long long)dims[2],
(long long)check_dims[0],
(long long)check_dims[1],
(long long)check_dims[2]));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"[%d] Block dimensions do not agree: "
"(%lld,%lld,%lld) != (%lld,%lld,%lld)!",
f->myproc,
(long long)dims[0],
(long long)dims[1],
(long long)dims[2],
(long long)check_dims[0],
(long long)check_dims[1],
(long long)check_dims[2]);
}
h5_int64_t coords[3];
TRY( h5b_3d_get_grid_coords((h5_file_t)f,
@@ -892,13 +895,15 @@ h5b_3d_set_halo (
(long long unsigned)k);
if ( !f->b->have_grid ) {
H5_LEAVE (
h5_error(H5_ERR_INVAL,
"Grid dimensions have not been set!"));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Grid dimensions have not been set!");
} else if ( !f->b->have_layout ) {
H5_LEAVE (
h5_error(H5_ERR_INVAL,
"Block dimensions for grid have not been set!"));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Block dimensions for grid have not been set!");
}
h5b_fdata_t *b = f->b;
+10 -9
View File
@@ -1317,8 +1317,9 @@ part_kway (
&m->f->props->comm
);
if (rc != METIS_OK) {
H5_LEAVE(
h5_error (H5_ERR, "ParMETIS failed"));
H5_RETURN_ERROR (
H5_ERR,
"ParMETIS failed");
}
TRY (h5_free (vtxdist));
TRY (h5_free (xadj));
@@ -2150,8 +2151,9 @@ distribute_octree_parmetis (
&m->f->props->comm
);
if (rc != METIS_OK) {
H5_LEAVE(
h5_error (H5_ERR, "ParMETIS failed"));
H5_RETURN_ERROR (
H5_ERR,
"ParMETIS failed");
}
TRY (h5_free (xadj));
@@ -2709,11 +2711,10 @@ read_elems_part (
i++; hcount++;
}
if (hstart+hcount > num_glb_elems) {
H5_LEAVE (
h5_error (
H5_ERR_H5FED,
"invalid selection: start=%lld, count=%lld",
(long long)hstart, (long long)hcount));
H5_RETURN_ERROR (
H5_ERR_H5FED,
"invalid selection: start=%lld, count=%lld",
(long long)hstart, (long long)hcount);
}
TRY (hdf5_select_hyperslab_of_dataspace (
dspace_id,
+5 -6
View File
@@ -500,12 +500,11 @@ h5priv_exchange_loc_list_to_glb (
// loc -> glb
for (int i = 0; i < m->marked_entities->num_items; i++) {
if (m->marked_entities->items[i] > m->last_stored_eid) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Element chosen to be refined is %d but there are only %d elements",
m->marked_entities->items[i],
m->last_stored_eid + 1 ));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Element chosen to be refined is %d but there are only %d elements",
m->marked_entities->items[i],
m->last_stored_eid + 1);
}
sendbuf[i] = h5tpriv_get_loc_elem_glb_idx (m, m->marked_entities->items[i]);
+4 -4
View File
@@ -386,10 +386,10 @@ h5t_close_mesh (
#endif
// check if tagsets are still open
if (m->mtagsets && m->mtagsets->num_items > 0)
H5_LEAVE (
h5_error (
H5_ERR_H5FED,
"Mesh cannot be closed: Mesh is referenced by open tagsets"));
H5_RETURN_ERROR (
H5_ERR_H5FED,
"%s",
"Mesh cannot be closed: Mesh is referenced by open tagsets");
if (!(m->f->props->flags & H5_O_RDONLY)) {
TRY (h5tpriv_write_mesh (m));
+5 -5
View File
@@ -591,10 +591,10 @@ update_userdata (
for (int j = i + 1; j < nbr_glb_oct_changed; j++) {
if (oct_idx_to_check == changed_oct_idx[j]) {
/*** an octant was changed twice! ***/
H5_LEAVE( h5_error (
H5_ERR_INVAL,
"Multiple cores tried to update the same userdata with idx: %d",
oct_idx_to_check));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Multiple cores tried to update the same userdata with idx: %d",
oct_idx_to_check);
};
};
};
@@ -3195,7 +3195,7 @@ complete_level(
parent = get_parent(octree, parent);
}
if (parent == -1){
H5_LEAVE (H5_ERR_INTERNAL );
H5_LEAVE (H5_ERR_INTERNAL);
}
done = 0;
// mark all parents of parent as not on level
+30 -22
View File
@@ -203,24 +203,27 @@ h5t_create_mtagset (
m, name, (long long unsigned)type, set);
// validate name
if (name == NULL || name[0] == '\0') {
H5_LEAVE (
h5_error (H5_ERR_INVAL, "Invalid name" ));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Invalid name");
}
// validate type
if (type != H5_INT64_T && type != H5_FLOAT64_T) {
H5_LEAVE (
h5_error (H5_ERR_INVAL, "Unsupported data type." ));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Unsupported data type.");
}
// check if a tagset with given name already exists
h5_err_t exists;
TRY (exists = h5priv_link_exists (m->mesh_gid, "Tags", name));
if (exists || h5priv_find_strlist (m->mtagsets, name) >= 0)
H5_LEAVE (
h5_error (
H5_ERR_H5FED,
"Cannot create tagset '%s': Tagset exists", name));
H5_RETURN_ERROR (
H5_ERR_H5FED,
"Cannot create tagset '%s': Tagset exists", name);
TRY (ret_value = new_tagset (m, m->mesh_gid, name, type, set));
H5_RETURN (ret_value);
}
@@ -509,23 +512,27 @@ h5t_open_mtagset (
m, name, set);
// validate name
if (name == NULL || name[0] == '\0') {
H5_LEAVE (
h5_error (H5_ERR_INVAL, "Invalid name" ));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"Invalid name");
}
// check if a tagset with given name exists
h5_err_t exists;
TRY (exists = h5priv_link_exists (m->mesh_gid, "Tags", name));
if (!exists) H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Cannot open tagset '%s': No such tagset ", name));
if (!exists)
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Cannot open tagset '%s': No such tagset ",
name);
// check if tagset has already been opened
if (h5priv_find_strlist (m->mtagsets, name) >= 0) H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Cannot open tagset '%s': Already open ", name));
if (h5priv_find_strlist (m->mtagsets, name) >= 0)
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Cannot open tagset '%s': Already open ",
name);
TRY (new_tagset (m, m->mesh_gid, name, -1, set));
@@ -765,10 +772,11 @@ h5t_remove_mtagset (
H5_CORE_API_ENTER (h5_err_t, "m=%p, name='%s'", m, name);
// check if tagset has a copy in memory
if (h5priv_find_strlist (m->mtagsets, name) >= 0) H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Cannot remove tagset '%s': Still open ", name));
if (h5priv_find_strlist (m->mtagsets, name) >= 0)
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Cannot remove tagset '%s': Still open ",
name);
hid_t loc_id;
TRY (loc_id = hdf5_open_group (m->mesh_gid, "Tags"));
+43 -52
View File
@@ -50,10 +50,10 @@ h5u_get_num_points_in_view (
h5_ssize_t nparticles;
if (!h5u_has_view (fh)) {
H5_LEAVE (
h5_error (
H5_ERR_H5PART,
"No view has been set."));
H5_RETURN_ERROR (
H5_ERR_H5PART,
"%s",
"No view has been set.");
}
TRY (nparticles = hdf5_get_selected_npoints_of_dataspace(f->u->diskshape));
h5_debug ("Found %lld particles in view.", (long long)nparticles );
@@ -118,11 +118,10 @@ h5u_set_num_points (
hsize_t dmax = H5S_UNLIMITED;
if (nparticles < 0)
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"Invalid number of particles: %lld!\n",
(long long)nparticles));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid number of particles: %lld!\n",
(long long)nparticles);
#ifndef PARALLEL_IO
/*
@@ -285,23 +284,19 @@ h5u_set_view (
:FIXME: why not gather total size?
*/
if (start < 0) {
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"Start of selection '%lld' out of range: "
"must be >= 0",
(long long)start)
);
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Start of selection '%lld' out of range: "
"must be >= 0",
(long long)start);
}
if (end < start) {
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"End of selection '%lld' out of range: "
"must be >= %lld",
(long long)end,
(long long)start)
);
H5_RETURN_ERROR (
H5_ERR_INVAL,
"End of selection '%lld' out of range: "
"must be >= %lld",
(long long)end,
(long long)start);
}
#if PARALLEL_IO
TRY (
@@ -322,25 +317,22 @@ h5u_set_view (
}
if (start < 0 || start >= total) {
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"Start of selection '%lld' out of range: "
"must be in [0..%lld]",
(long long)start, (long long)total-1));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Start of selection '%lld' out of range: "
"must be in [0..%lld]",
(long long)start, (long long)total-1);
} else if (end < 0 || end >= total) {
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"End of selection '%lld' out of range: "
"must be in [0..%lld]",
(long long)end, (long long)total-1));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"End of selection '%lld' out of range: "
"must be in [0..%lld]",
(long long)end, (long long)total-1);
} else if (end+1 < start) {
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"Invalid selection: start=%lld > end=%lld!\n",
(long long)start, (long long)end));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid selection: start=%lld > end=%lld!\n",
(long long)start, (long long)end);
}
}
@@ -408,12 +400,11 @@ h5u_set_view_length (
}
if (start < 0 || length < 0 || start+length > total)
H5_LEAVE (
h5_error(
H5_ERR_INVAL,
"Invalid view: start=%lld, length=%lld, total=%lld",
(long long)start, (long long)length,
(long long)total));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Invalid view: start=%lld, length=%lld, total=%lld",
(long long)start, (long long)length,
(long long)total);
/* setting up the new view */
u->viewstart = start;
@@ -517,11 +508,11 @@ h5u_get_view (
struct h5u_fdata *u = f->u;
if ( u->viewindexed ) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"The current view has an index selection, but "
"this function only works for ranged views." ));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"%s",
"The current view has an index selection, but "
"this function only works for ranged views." );
}
h5_int64_t viewstart = 0;
+11 -12
View File
@@ -65,14 +65,13 @@ h5priv_read_attrib (
hid_t normalized_file_type;
TRY (normalized_file_type = h5priv_normalize_type (file_type));
if (normalized_file_type != normalized_type)
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Attribute '%s' has type '%s' but "
"was requested as '%s'.",
attrib_name,
hdf5_get_type_name (normalized_file_type),
hdf5_get_type_name (normalized_type)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Attribute '%s' has type '%s' but "
"was requested as '%s'.",
attrib_name,
hdf5_get_type_name (normalized_file_type),
hdf5_get_type_name (normalized_type));
if (normalized_type == H5_STRING) {
mem_type = file_type;
} else {
@@ -120,10 +119,10 @@ h5priv_write_attrib (
if (overwrite) {
TRY (hdf5_delete_attribute (id, attrib_name));
} else {
H5_LEAVE (
h5_error (H5_ERR_H5,
"Cannot overwrite attribute %s/%s",
hdf5_get_objname (id), attrib_name));
H5_RETURN_ERROR (
H5_ERR,
"Cannot overwrite attribute %s/%s",
hdf5_get_objname (id), attrib_name);
}
}
TRY (attrib_id = hdf5_create_attribute (
+34 -40
View File
@@ -40,10 +40,10 @@ h5priv_link_exists_ (
*s++ = '/';
*s = '\0';
}
if (s+strlen(path[i])+1 >= end) H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"path %s... to long", name));
if (s+strlen(path[i])+1 >= end)
H5_RETURN_ERROR (
H5_ERR_HDF5,
"path %s... to long", name);
s = stpcpy (s, path[i]); // return ptr to end!!!
h5_err_t exists;
TRY (exists = hdf5_link_exists (loc_id, name));
@@ -73,12 +73,11 @@ h5priv_open_group_ (
} else if (create_intermediate) {
TRY (hid2 = hdf5_create_group (hid, path[i]));
} else {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"No such group '%s/%s'.",
hdf5_get_objname (hid),
path[i]));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"No such group '%s/%s'.",
hdf5_get_objname (hid),
path[i]);
}
if (hid != loc_id) {
@@ -237,11 +236,10 @@ hdf5_get_num_groups (
&start_idx,
iter_op_count, &op_data);
if (herr < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot get number of groups in '%s'.",
hdf5_get_objname (loc_id)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot get number of groups in '%s'.",
hdf5_get_objname (loc_id));
}
H5_RETURN (op_data.cnt);
}
@@ -263,12 +261,11 @@ hdf5_get_num_groups_matching_prefix (
&start_idx,
iter_op_count_match, &op_data);
if (herr < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot get number of groups with prefix"
" '%s' in '%s'.",
prefix, hdf5_get_objname (loc_id)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot get number of groups with prefix"
" '%s' in '%s'.",
prefix, hdf5_get_objname (loc_id));
}
H5_RETURN (op_data.cnt);
}
@@ -296,13 +293,12 @@ hdf5_get_name_of_group_by_idx (
&start_idx,
iter_op_idx, &op_data);
if (herr < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot get name of group with index"
" '%lu' in '%s'.",
(long unsigned int)idx,
hdf5_get_objname (loc_id)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot get name of group with index"
" '%lu' in '%s'.",
(long unsigned int)idx,
hdf5_get_objname (loc_id));
}
H5_RETURN (H5_SUCCESS);
}
@@ -322,11 +318,10 @@ hdf5_get_num_datasets (
&start_idx,
iter_op_count, &op_data);
if (herr < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot get number of datasets in '%s'.",
hdf5_get_objname (loc_id)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot get number of datasets in '%s'.",
hdf5_get_objname (loc_id));
}
H5_RETURN (op_data.cnt);
}
@@ -357,13 +352,12 @@ hdf5_get_name_of_dataset_by_idx (
&start_idx,
iter_op_idx, &op_data);
if (herr < 0) {
H5_LEAVE (
h5_error (
H5_ERR_HDF5,
"Cannot get name of dataset with index"
" '%lu' in '%s'.",
(long unsigned int)idx,
hdf5_get_objname (loc_id)));
H5_RETURN_ERROR (
H5_ERR_HDF5,
"Cannot get name of dataset with index"
" '%lu' in '%s'.",
(long unsigned int)idx,
hdf5_get_objname (loc_id));
}
if (op_data.cnt < 0)
H5_LEAVE (H5_NOK);
File diff suppressed because it is too large Load Diff
+9 -12
View File
@@ -159,10 +159,9 @@ h5priv_map_enum_to_normalized_type (
ret_value = H5_FLOAT64;
break;
default:
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Unknown type %d", (int)type));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Unknown type %d", (int)type);
}
H5_RETURN (ret_value);
}
@@ -220,10 +219,9 @@ h5priv_normalize_type (
break;
}
if (ret_value < 0) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Unknown type %d", (int)type));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Unknown type %d", (int)type);
}
H5_RETURN (ret_value);
}
@@ -280,10 +278,9 @@ h5priv_map_hdf5_type_to_enum (
ret_value = H5_STRING_T;
break;
default:
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Unknown type %d", (int)type));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Unknown type %d", (int)type);
}
H5_RETURN (ret_value);
}
+85 -42
View File
@@ -42,10 +42,10 @@ h5priv_mpi_alltoall (
recvtype,
comm);
if (err != MPI_SUCCESS)
H5_LEAVE (
h5_error (
H5_ERR_MPI,
"Cannot perform all to all communication"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot perform all to all communication");
H5_RETURN (H5_SUCCESS);
}
@@ -78,10 +78,10 @@ h5priv_mpi_alltoallv (
recvtype,
comm);
if (err != MPI_SUCCESS)
H5_LEAVE (
h5_error (
H5_ERR_MPI,
"Cannot perform all to all communication"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot perform all to all communication");
H5_RETURN (H5_SUCCESS);
}
@@ -93,10 +93,10 @@ h5priv_mpi_barrier (
MPI_WRAPPER_ENTER (h5_err_t, "comm=%p",&comm);
int err = MPI_Barrier(comm);
if (err != MPI_SUCCESS)
H5_LEAVE (
h5_error (
H5_ERR_MPI,
"MPI Barrier was not successful"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"MPI Barrier was not successful");
H5_RETURN (H5_SUCCESS);
}
@@ -123,7 +123,10 @@ h5priv_mpi_recv(
MPI_STATUS_IGNORE
);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot receive data"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot receive data");
H5_RETURN (H5_SUCCESS);
}
@@ -148,7 +151,10 @@ h5priv_mpi_send(
comm
);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot send data"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot send data");
H5_RETURN (H5_SUCCESS);
}
@@ -171,7 +177,10 @@ h5priv_mpi_bcast (
comm
);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform broadcast"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot perform broadcast");
H5_RETURN (H5_SUCCESS);
}
@@ -195,7 +204,10 @@ h5priv_mpi_sum (
comm
);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform MPI_SUM reduction"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot perform MPI_SUM reduction");
H5_RETURN (H5_SUCCESS);
}
@@ -218,8 +230,10 @@ h5priv_mpi_allreduce_max (
MPI_MAX,
comm
) != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI,
"Cannot perform MPI_MAX reduction"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot perform MPI_MAX reduction");
H5_RETURN (H5_SUCCESS);
}
@@ -243,7 +257,10 @@ h5priv_mpi_prefix_sum (
comm
);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform prefix sum"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot perform prefix sum");
H5_RETURN (H5_SUCCESS);
}
@@ -271,7 +288,10 @@ mpi_allgather (
recvtype,
comm);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot gather data");
H5_RETURN (H5_SUCCESS);
}
#define h5priv_mpi_allgatherv mpi_allgatherv
@@ -301,7 +321,10 @@ mpi_allgatherv (
recvtype,
comm);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot gather data");
H5_RETURN (H5_SUCCESS);
}
@@ -314,7 +337,10 @@ h5priv_mpi_comm_size (
MPI_WRAPPER_ENTER (h5_err_t, "comm=?, size=%p", size);
int err = MPI_Comm_size (comm, size);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot get communicator size"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot get communicator size");
H5_RETURN (H5_SUCCESS);
}
@@ -326,7 +352,10 @@ h5priv_mpi_comm_rank (
MPI_WRAPPER_ENTER (h5_err_t, "comm=?, rank=%p", rank);
int err = MPI_Comm_rank (comm, rank);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot get this task's rank"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot get this task's rank");
H5_RETURN (H5_SUCCESS);
}
@@ -342,10 +371,16 @@ h5priv_mpi_type_contiguous (
int err;
err = MPI_Type_contiguous ( nelems, oldtype, newtype );
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot create new MPI type"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot create new MPI type");
err = MPI_Type_commit ( newtype );
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot commit new MPI type"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot commit new MPI type");
H5_RETURN (H5_SUCCESS);
}
@@ -358,10 +393,9 @@ mpi_get_address (
MPI_WRAPPER_ENTER (h5_err_t, "location=%p, address=%p", location, address);
int err = MPI_Get_address (location, address);
if (err != MPI_SUCCESS) {
H5_LEAVE (
h5_error (
H5_ERR_MPI,
"Cannot get MPI address of location=%p", location));
H5_RETURN_ERROR (
H5_ERR_MPI,
"Cannot get MPI address of location=%p", location);
}
H5_RETURN (H5_SUCCESS);
}
@@ -380,10 +414,10 @@ mpi_create_type_struct (
count, blocklens, indices, old_types, new_type);
int err = MPI_Type_create_struct (count, blocklens, indices, old_types, new_type);
if (err != MPI_SUCCESS) {
H5_LEAVE (
h5_error (
H5_ERR_MPI,
"Cannot create new MPI struct"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot create new MPI struct");
}
H5_RETURN (H5_SUCCESS);
}
@@ -394,12 +428,12 @@ h5priv_mpi_type_commit (
) {
MPI_WRAPPER_ENTER (h5_err_t, "type=%p", type);
int err = MPI_Type_commit (type);
if (err != MPI_SUCCESS) {
H5_LEAVE (
h5_error (
H5_ERR_MPI,
"Cannot commit MPI datatype"));
}
if (err != MPI_SUCCESS) {
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot commit MPI datatype");
}
H5_RETURN (H5_SUCCESS);
}
@@ -411,7 +445,10 @@ h5priv_mpi_type_free (
MPI_WRAPPER_ENTER (h5_err_t, "type=%p", type);
int err = MPI_Type_free( type );
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot free MPI type"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot free MPI type");
H5_RETURN (H5_SUCCESS);
}
@@ -430,7 +467,10 @@ h5priv_mpi_cart_create (
int err = MPI_Cart_create(
old_comm, ndims, dims, period, reorder, new_comm);
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot create cartesian grid");
H5_RETURN (H5_SUCCESS);
}
@@ -445,7 +485,10 @@ h5priv_mpi_cart_coords (
rank, maxdim, coords);
int err = MPI_Cart_coords( comm, rank, maxdim, coords );
if (err != MPI_SUCCESS)
H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid"));
H5_RETURN_ERROR (
H5_ERR_MPI,
"%s",
"Cannot create cartesian grid");
H5_RETURN (H5_SUCCESS);
}
+8 -10
View File
@@ -151,11 +151,10 @@ h5t_add_tetrahedral_mesh (
TETRAHEDRAL_MESHES_GRPNAME,
name));
if (exists) {
H5_LEAVE (
h5_error (
H5_ERR,
"Tetrahedral mesh '%s' already exists!",
name));
H5_RETURN_ERROR (
H5_ERR,
"Tetrahedral mesh '%s' already exists!",
name);
}
hid_t mesh_hid;
TRY (mesh_hid = h5priv_open_group (
@@ -209,11 +208,10 @@ h5t_add_chunked_tetrahedral_mesh (
TETRAHEDRAL_MESHES_GRPNAME,
name));
if (exists) {
H5_LEAVE (
h5_error (
H5_ERR,
"Tetrahedral mesh '%s' already exists!",
name));
H5_RETURN_ERROR (
H5_ERR,
"Tetrahedral mesh '%s' already exists!",
name);
}
hid_t mesh_hid;
TRY (mesh_hid = h5priv_open_group (
+12 -15
View File
@@ -170,11 +170,10 @@ h5t_add_triangle_mesh (
TRIANGLE_MESHES_GRPNAME,
name));
if (exists) {
H5_LEAVE (
h5_error (
H5_ERR,
"Tetrahedral mesh '%s' already exists!",
name));
H5_RETURN_ERROR (
H5_ERR,
"Tetrahedral mesh '%s' already exists!",
name);
}
hid_t mesh_hid;
TRY (mesh_hid = h5priv_open_group (
@@ -221,11 +220,10 @@ h5t_add_chunked_triangle_mesh(
int size = -1;
TRY (h5priv_mpi_comm_size (f->props->comm, &size));
if (size != 1) {
H5_LEAVE (
h5_error (
H5_ERR,
"Trying to create a chunked mesh with '%d' procs instead of 1!",
size));
H5_RETURN_ERROR (
H5_ERR,
"Trying to create a chunked mesh with '%d' procs instead of 1!",
size);
}
CHECK_WRITABLE_MODE (f);
@@ -236,11 +234,10 @@ h5t_add_chunked_triangle_mesh(
TRIANGLE_MESHES_GRPNAME,
name));
if (exists) {
H5_LEAVE (
h5_error (
H5_ERR,
"Triangle mesh '%s' already exists!",
name));
H5_RETURN_ERROR (
H5_ERR,
"Triangle mesh '%s' already exists!",
name);
}
hid_t mesh_hid;
TRY (mesh_hid = h5priv_open_group (
+10 -12
View File
@@ -151,11 +151,10 @@ refine_tet (
h5_loc_tet_t* el = (h5_loc_tet_t*)m->loc_elems + elem_idx;
if ( el->child_idx >= 0 )
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Tetrahedron %lld already refined.",
(long long)elem_idx ));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Tetrahedron %lld already refined.",
(long long)elem_idx);
vertices[0] = el->vertex_indices[0];
vertices[1] = el->vertex_indices[1];
vertices[2] = el->vertex_indices[2];
@@ -312,13 +311,12 @@ compute_neighbors_of_elems (
) {
H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, level=%d", m, level);
if (level < 0 || level >= m->num_leaf_levels) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"level idx %lld out of bound, must be in [%lld,%lld]",
(long long)level,
(long long)0,
(long long)m->num_leaf_levels));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"level idx %lld out of bound, must be in [%lld,%lld]",
(long long)level,
(long long)0,
(long long)m->num_leaf_levels);
}
h5_loc_idx_t elem_idx = level == 0 ? 0 : m->num_interior_elems[level-1];
const h5_loc_idx_t last_idx = m->num_interior_elems[level] - 1;
+10 -12
View File
@@ -130,11 +130,10 @@ refine_triangle (
h5_loc_tri_t* el = (h5_loc_tri_t*)m->loc_elems + elem_idx;
if (el->child_idx >= 0)
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"Element %lld already refined.",
(long long)elem_idx));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"Element %lld already refined.",
(long long)elem_idx);
vertices[0] = el->vertex_indices[0];
vertices[1] = el->vertex_indices[1];
@@ -236,13 +235,12 @@ compute_neighbors_of_elems (
) {
H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, level=%d", m, level);
if (level < 0 || level >= m->num_leaf_levels) {
H5_LEAVE (
h5_error (
H5_ERR_INVAL,
"level idx %lld out of bound, must be in [%lld,%lld]",
(long long)level,
(long long)0,
(long long)m->num_leaf_levels));
H5_RETURN_ERROR (
H5_ERR_INVAL,
"level idx %lld out of bound, must be in [%lld,%lld]",
(long long)level,
(long long)0,
(long long)m->num_leaf_levels);
}
h5_loc_idx_t elem_idx = level == 0 ? 0 : m->num_interior_elems[level-1];
const h5_loc_idx_t last_idx = m->num_interior_elems[level] - 1;
+9 -4
View File
@@ -214,9 +214,14 @@ h5_get_loglevel (
//////////////////////////////////////////////////////////////////////////////
#define H5_LEAVE(expr) { \
ret_value = expr; \
goto done; \
}
ret_value = expr; \
goto done; \
}
#define H5_RETURN_ERROR(errno, fmt, ...) { \
ret_value = h5_error (errno, "(" fmt ")", __VA_ARGS__); \
goto done; \
}
//////////////////////////////////////////////////////////////////////////////
// function return macro
@@ -234,7 +239,7 @@ done: \
ret_value = expr; \
goto done; \
done: \
if (__log__ ) { \
if (__log__ ) { \
char fmt[256]; \
snprintf (fmt, sizeof(fmt), "return: %s", \
h5_rfmts[h5_call_stack_get_type()]); \