From f97e3c8f2d6e4f28f0f29550bb189c1405995f10 Mon Sep 17 00:00:00 2001 From: Achim Gsell Date: Fri, 24 Jun 2016 15:51:39 +0200 Subject: [PATCH] core API: - debugging macros simplified - cleanup - h5_delete_attachment(): check of file mode added --- src/h5core/Makefile.am | 5 +- src/h5core/h5_attachments.c | 45 +- src/h5core/h5_attribs.c | 24 +- src/h5core/h5_file.c | 71 +-- src/h5core/h5_model.c | 12 +- src/h5core/h5_syscall.c | 99 ++++ src/h5core/h5b_attribs.c | 16 +- src/h5core/h5b_io.c | 32 +- src/h5core/h5b_model.c | 54 +-- src/h5core/h5t_adjacencies.c | 6 +- src/h5core/h5t_io.c | 545 +++++++++------------- src/h5core/h5t_map.c | 65 +-- src/h5core/h5t_model.c | 50 +- src/h5core/h5t_octree.c | 526 +++++++++++---------- src/h5core/h5t_retrieve.c | 36 +- src/h5core/h5t_store.c | 474 +++++++++---------- src/h5core/h5t_tags.c | 70 +-- src/h5core/h5u_io.c | 8 +- src/h5core/h5u_model.c | 76 +-- src/h5core/private/h5_attribs.h | 16 +- src/h5core/private/h5_hdf5.c | 38 +- src/h5core/private/h5_hdf5.h | 287 ++++++------ src/h5core/private/h5_hsearch.c | 28 +- src/h5core/private/h5_init.c | 28 +- src/h5core/private/h5_io.c | 8 +- src/h5core/private/h5_log.h | 44 +- src/h5core/private/h5_lustre.c | 2 +- src/h5core/private/h5_maps.c | 40 +- src/h5core/private/h5_maps.h | 22 +- src/h5core/private/h5_model.h | 25 +- src/h5core/private/h5_mpi.h | 85 ++-- src/h5core/private/h5t_access_tetm.c | 17 +- src/h5core/private/h5t_access_trim.c | 13 +- src/h5core/private/h5t_adjacencies.h | 4 +- src/h5core/private/h5t_adjacencies_tetm.c | 44 +- src/h5core/private/h5t_adjacencies_trim.c | 26 +- src/h5core/private/h5t_core.c | 30 +- src/h5core/private/h5t_core.h | 8 +- src/h5core/private/h5t_core_tetm.c | 10 +- src/h5core/private/h5t_core_trim.c | 10 +- src/h5core/private/h5t_io.h | 8 +- src/h5core/private/h5t_io_tetm.c | 12 +- src/h5core/private/h5t_io_trim.c | 10 +- src/h5core/private/h5t_map.h | 6 +- src/h5core/private/h5t_model_tetm.c | 14 +- src/h5core/private/h5t_model_trim.c | 16 +- src/h5core/private/h5t_octree.h | 4 +- src/h5core/private/h5t_store_tetm.c | 26 +- src/h5core/private/h5t_store_trim.c | 32 +- src/include/h5core/h5_log.h | 176 +++---- src/include/h5core/h5_syscall.h | 76 +-- 51 files changed, 1664 insertions(+), 1715 deletions(-) create mode 100644 src/h5core/h5_syscall.c diff --git a/src/h5core/Makefile.am b/src/h5core/Makefile.am index b9f4679..6953588 100644 --- a/src/h5core/Makefile.am +++ b/src/h5core/Makefile.am @@ -48,10 +48,11 @@ lib_LTLIBRARIES = libH5hut.la libH5hut_la_SOURCES = \ h5_attachments.c \ h5_attribs.c \ - h5_log.c \ h5_err.c \ - h5_model.c \ + h5_log.c \ h5_file.c \ + h5_model.c \ + h5_syscall.c \ h5u_io.c \ h5b_io.c \ h5u_model.c \ diff --git a/src/h5core/h5_attachments.c b/src/h5core/h5_attachments.c index 3c62cc5..a6c9858 100644 --- a/src/h5core/h5_attachments.c +++ b/src/h5core/h5_attachments.c @@ -32,13 +32,13 @@ h5_add_attachment ( H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname); // allowed file modes: O_RDWR, O_WRONLY; O_APPEND if (f->props->flags & H5_O_RDONLY) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5priv_handle_file_mode_error (f->props->flags)); } struct stat st; if (stat (fname, &st) < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot stat file '%s'", @@ -52,7 +52,7 @@ h5_add_attachment ( write_length = fsize; int fd; if ((fd = open (fname, O_RDONLY)) < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot open file '%s' for reading", @@ -63,7 +63,7 @@ h5_add_attachment ( if (errno == EINTR) { goto again; } else { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot read file '%s'", @@ -71,7 +71,7 @@ h5_add_attachment ( } } if (close (fd) < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot close file '%s'", @@ -88,7 +88,7 @@ h5_add_attachment ( h5_err_t exists; TRY (exists = hdf5_link_exists (loc_id, fname)); if (exists && (f->props->flags & H5_O_APPENDONLY)) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5priv_handle_file_mode_error (f->props->flags)); } hid_t diskspace_id; @@ -125,7 +125,7 @@ h5_add_attachment ( TRY (h5_free (buf)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -135,7 +135,7 @@ h5_has_attachments ( h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); TRY (ret_value = hdf5_link_exists (f->file, H5_ATTACHMENT)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_ssize_t @@ -153,7 +153,7 @@ h5_get_num_attachments ( TRY (group_id = hdf5_open_group (f->file, H5_ATTACHMENT)); TRY (ret_value = hdf5_get_num_datasets (group_id)); TRY (hdf5_close_group (group_id)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -184,7 +184,7 @@ h5_get_attachment_info_by_idx ( *fsize = ssize; } TRY (hdf5_close_group (loc_id)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -197,7 +197,7 @@ h5_has_attachment ( hid_t loc_id; TRY (loc_id = hdf5_open_group (f->file, H5_ATTACHMENT)); TRY (ret_value = hdf5_link_exists (f->file, fname)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -218,7 +218,7 @@ h5_get_attachment_info_by_name ( *fsize = ssize; } TRY (hdf5_close_group (loc_id)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -231,7 +231,7 @@ h5_get_attachment ( // allowed modes: O_RDWR, O_RDONLY; O_APPEND // forbidden modes: O_WRONLY if (f->props->flags & H5_O_WRONLY) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5priv_handle_file_mode_error (f->props->flags)); } @@ -248,11 +248,11 @@ h5_get_attachment ( hsize_t read_length; char* buf = NULL; if (f->myproc == 0) { - buf = malloc (fsize); + buf = h5_calloc (1, fsize); read_length = fsize; } else { - buf = malloc (1); + buf = h5_calloc (1, 1); read_length = 0; } @@ -284,21 +284,21 @@ h5_get_attachment ( if (f->myproc == 0) { int fd; if ((fd = open (fname, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5, "Error opening file '%s': %s", fname, strerror(errno))); } if (write (fd, buf, fsize) != fsize) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5, "Error writing to file '%s': %s", fname, strerror(errno))); } if (close (fd) < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5, "Error closing file '%s': %s", @@ -307,7 +307,7 @@ h5_get_attachment ( } TRY (h5_free (buf)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -317,10 +317,15 @@ h5_delete_attachment ( ) { h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (h5_err_t, "f=%p, fname='%s'", f, fname); + // allowed file modes: O_RDWR, O_WRONLY; O_APPEND + if (f->props->flags & H5_O_RDONLY) { + H5_LEAVE ( + h5priv_handle_file_mode_error (f->props->flags)); + } hid_t loc_id; TRY (loc_id = hdf5_open_group (f->file, H5_ATTACHMENT)); TRY (hdf5_delete_link (loc_id, fname, H5P_DEFAULT)); TRY (hdf5_close_group (loc_id)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5_attribs.c b/src/h5core/h5_attribs.c index ebda48c..dd9ecd2 100644 --- a/src/h5core/h5_attribs.c +++ b/src/h5core/h5_attribs.c @@ -28,7 +28,7 @@ h5_has_file_attrib ( attrib_name); CHECK_FILEHANDLE (f); TRY (ret_value = hdf5_attribute_exists(f->root_gid, attrib_name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -44,7 +44,7 @@ h5_has_step_attrib ( attrib_name); CHECK_FILEHANDLE (f); TRY (ret_value = hdf5_attribute_exists (f->step_gid, attrib_name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_ssize_t @@ -55,7 +55,7 @@ h5_get_num_file_attribs ( H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); CHECK_FILEHANDLE (f); TRY (ret_value = hdf5_get_num_attribute (f->root_gid)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_ssize_t @@ -67,7 +67,7 @@ h5_get_num_step_attribs ( CHECK_FILEHANDLE (f); CHECK_TIMEGROUP (f); TRY (ret_value = hdf5_get_num_attribute (f->step_gid)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -95,7 +95,7 @@ h5_get_file_attrib_info_by_idx ( attrib_idx, attrib_name, len_attrib_name, attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -118,7 +118,7 @@ h5_get_file_attrib_info_by_name ( f->root_gid, attrib_name, attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } @@ -148,7 +148,7 @@ h5_get_step_attrib_info_by_idx ( attrib_idx, attrib_name, len_attrib_name, attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -172,7 +172,7 @@ h5_get_step_attrib_info_by_name ( f->step_gid, attrib_name, attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -196,7 +196,7 @@ h5_read_file_attrib ( attrib_name, attrib_type, attrib_value)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -222,7 +222,7 @@ h5_read_step_attrib ( attrib_name, attrib_type, attrib_value)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } @@ -252,7 +252,7 @@ h5_write_file_attrib ( attrib_value, attrib_nelem, !is_appendonly (f))); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -282,7 +282,7 @@ h5_write_step_attrib ( attrib_value, attrib_nelem, !is_appendonly (f))); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } diff --git a/src/h5core/h5_file.c b/src/h5core/h5_file.c index 893363a..e62a6ff 100644 --- a/src/h5core/h5_file.c +++ b/src/h5core/h5_file.c @@ -10,6 +10,7 @@ #include #include #include +#include #include "h5core/h5_log.h" @@ -55,7 +56,7 @@ h5_get_hdf5_file( ) { h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (hid_t, "f=%p", f); - H5_CORE_API_RETURN (f->file); + H5_RETURN (f->file); } /*! @@ -140,7 +141,7 @@ mpi_init ( } #endif #endif /* PARALLEL_IO */ - H5_INLINE_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -162,7 +163,7 @@ set_alignment ( (long long int)f->props->align); TRY (H5Pset_meta_block_size (f->props->access_prop, f->props->align)); } - H5_INLINE_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -180,7 +181,7 @@ set_default_file_props ( H5_STEPNAME_LEN - 1); props->width_step_idx = H5_STEPWIDTH; props->comm = MPI_COMM_WORLD; - H5_INLINE_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -192,7 +193,7 @@ 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_INLINE_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", @@ -206,7 +207,7 @@ h5_set_prop_file_mpio_collective ( props->throttle = 0; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -218,7 +219,7 @@ 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_INLINE_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", @@ -227,7 +228,7 @@ h5_set_prop_file_mpio_independent ( props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE); props->flags |= H5_VFD_MPIO_INDEPENDENT; props->comm = *comm; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if H5_VERSION_LE(1,8,12) @@ -240,7 +241,7 @@ 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_INLINE_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", @@ -249,7 +250,7 @@ h5_set_prop_file_mpio_posix ( props->flags &= ~(H5_VFD_MPIO_COLLECTIVE | H5_VFD_MPIO_POSIX | H5_VFD_CORE); props->flags |= H5_VFD_MPIO_INDEPENDENT; props->comm = *comm; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -262,7 +263,7 @@ 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_INLINE_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", @@ -276,7 +277,7 @@ h5_set_prop_file_core_vfd ( h5_warn ("Throttling is not permitted with core VFD. Reset throttling."); props->throttle = 0; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -291,14 +292,14 @@ h5_set_prop_file_align ( "props=%p, align=%lld", props, (long long int)align); if (props->class != H5_PROP_FILE) { - H5_INLINE_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", (long long int)props->class)); } props->align = align; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -312,7 +313,7 @@ h5_set_prop_file_throttle ( "props=%p, throttle=%lld", props, (long long int)throttle); if (props->class != H5_PROP_FILE) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", @@ -337,7 +338,7 @@ h5_set_prop_file_throttle ( } props->throttle = throttle; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -356,13 +357,13 @@ h5_create_prop ( set_default_file_props ((h5_prop_file_t*)prop); break; default: - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", (long long int)class)); } - H5_CORE_API_RETURN ((h5_prop_t)prop); + H5_RETURN ((h5_prop_t)prop); } h5_err_t @@ -378,13 +379,13 @@ h5_close_prop ( break; } default: - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld", (long long int)prop->class)); } - H5_CORE_API_RETURN (h5_free (prop)); + H5_RETURN (h5_free (prop)); } static inline h5_err_t @@ -440,7 +441,7 @@ open_file ( } } else { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid file access mode '%lld'.", @@ -448,7 +449,7 @@ open_file ( } if (f->file < 0) - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot open file '%s' with mode '%s'", @@ -458,7 +459,7 @@ open_file ( TRY (h5upriv_open_file (f)); TRY (h5bpriv_open_file (f)); - H5_INLINE_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_file_t @@ -481,7 +482,7 @@ h5_open_file2 ( if (props != H5_PROP_DEFAULT) { if (props->class != H5_PROP_FILE) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Invalid property class: %lld.", @@ -501,7 +502,7 @@ h5_open_file2 ( TRY (open_file (f, filename, mode)); - H5_CORE_API_RETURN ((h5_file_t)f); + H5_RETURN ((h5_file_t)f); } /*! @@ -539,7 +540,7 @@ h5_open_file1 ( TRY (f = h5_open_file2 (filename, mode, (h5_prop_t)props)); TRY (h5_close_prop ((h5_prop_t)props)); h5_file_p _f = (h5_file_p)f; - H5_CORE_API_RETURN (_f); + H5_RETURN (_f); } @@ -574,7 +575,7 @@ h5_close_file ( TRY (hdf5_close_file (f->file)); TRY (h5_free (f->step_name)); TRY (h5_free (f)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -583,7 +584,7 @@ h5_close_hdf5 ( ) { H5_CORE_API_ENTER (h5_err_t, "%s", ""); TRY (ret_value = hdf5_close ()); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -593,7 +594,7 @@ h5_flush_step ( h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (h5_err_t, "f=%p", f); TRY (ret_value = hdf5_flush (f->step_gid, H5F_SCOPE_LOCAL)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -603,7 +604,7 @@ h5_flush_file ( h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (h5_err_t, "f=%p", f); TRY (ret_value = hdf5_flush (f->file, H5F_SCOPE_GLOBAL)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } @@ -635,7 +636,7 @@ h5_set_stepname_fmt ( H5_STEPNAME_LEN - 1); f->props->width_step_idx = width; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -673,7 +674,7 @@ h5_get_step ( ) { h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (h5_id_t, "f=%p", f); - H5_CORE_API_RETURN (f->step_idx); + H5_RETURN (f->step_idx); } /*! @@ -689,7 +690,7 @@ h5_get_num_procs ( ) { h5_file_p f = (h5_file_p)f_; H5_CORE_API_ENTER (int, "f=%p", f); - H5_CORE_API_RETURN (f->nprocs); + H5_RETURN (f->nprocs); } /*! @@ -708,7 +709,7 @@ h5_get_num_steps( TRY (ret_value = hdf5_get_num_groups_matching_prefix ( f->root_gid, f->props->prefix_step_name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } /*! @@ -731,7 +732,7 @@ h5_start_traverse_steps ( loop over all steps and get smallest step number */ - H5_CORE_API_RETURN (h5_error_not_implemented ()); + H5_RETURN (h5_error_not_implemented ()); } /*! diff --git a/src/h5core/h5_model.c b/src/h5core/h5_model.c index b2c2836..3334985 100644 --- a/src/h5core/h5_model.c +++ b/src/h5core/h5_model.c @@ -20,12 +20,12 @@ h5priv_close_step ( ) { H5_PRIV_API_ENTER (h5_err_t, "f=%p", f); if (f->step_gid <= 0) - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); TRY (hdf5_close_group (f->step_gid)); f->step_gid = -1; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -53,7 +53,7 @@ h5_set_step ( TRY (f->step_gid = h5priv_open_group (is_writable(f), f->file, f->step_name)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -75,7 +75,7 @@ h5_has_step ( f->props->prefix_step_name, f->props->width_step_idx, (long long)step_idx); TRY (ret_value = hdf5_link_exists (f->file, name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -93,12 +93,12 @@ h5priv_normalize_dataset_name ( } if ( strcmp( name2, H5BLOCK_GROUPNAME_BLOCK ) == 0 ) { - H5_CORE_API_LEAVE ( + 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_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5_syscall.c b/src/h5core/h5_syscall.c new file mode 100644 index 0000000..22ed3b1 --- /dev/null +++ b/src/h5core/h5_syscall.c @@ -0,0 +1,99 @@ +/* + Copyright (c) 2006-2016, The Regents of the University of California, + through Lawrence Berkeley National Laboratory (subject to receipt of any + required approvals from the U.S. Dept. of Energy) and the Paul Scherrer + Institut (Switzerland). All rights reserved. + + License: see file COPYING in top level of source distribution. +*/ + +#ifndef __H5CORE_H5_SYSCALL_H +#define __H5CORE_H5_SYSCALL_H + +#include +#include + +#include "h5core/h5_types.h" +#include "private/h5_log.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define MALLOC_WRAPPER_ENTER(type, fmt, ...) \ + __FUNC_ENTER(type, H5_DEBUG_MALLOC, fmt, __VA_ARGS__) + +h5_err_t +h5_free ( + void* ptr + ) { + MALLOC_WRAPPER_ENTER (h5_err_t, "ptr=%p", ptr); + if (ptr) { + free (ptr); + } + H5_RETURN (H5_SUCCESS); +} + + +void_p +h5_alloc ( + void* ptr, + const size_t size + ) { + MALLOC_WRAPPER_ENTER (void_p, "ptr=%p, size=%lu", ptr, size); + if (size < 1) { + ret_value = (void_p) h5_free (ptr); + H5_LEAVE (NULL); + } + ptr = realloc (ptr, size); + if (ptr == NULL) { + H5_LEAVE ( + (void_p)h5_error ( + H5_ERR_NOMEM, + "Out of memory. Tried to alloc %lld", (long long int)size)); + } + H5_RETURN (ptr); +} + +void_p +h5_calloc ( + const size_t count, + const size_t size + ) { + MALLOC_WRAPPER_ENTER (void_p, "count=%zu , size=%zu", count, size); + void* ptr = NULL; + if (count * size < 1) { + H5_LEAVE (ptr); + } + ptr = calloc (count, size); + if (ptr == NULL) { + H5_LEAVE ( + (void_p)h5_error ( + H5_ERR_NOMEM, + "Out of memory. Tried to alloc %lld", (long long int)count* size)); + } + H5_RETURN (ptr); +} + + +char_p +h5_strdup ( + const char* s1 + ) { + MALLOC_WRAPPER_ENTER (char_p, "s='%s'", s1); + + char_p s2 = (char_p)h5_calloc (1, strlen (s1)+1 ); + if (s2 == NULL) { + H5_LEAVE ( + (char_p)h5_error ( + H5_ERR_NOMEM, + "Out of memory.")); + } + H5_RETURN (strcpy (s2, s1)); +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/h5core/h5b_attribs.c b/src/h5core/h5b_attribs.c index 60425aa..5701c90 100644 --- a/src/h5core/h5b_attribs.c +++ b/src/h5core/h5b_attribs.c @@ -47,7 +47,7 @@ h5b_write_field_attrib ( attrib_nelem, !is_appendonly (f)) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -79,7 +79,7 @@ h5b_read_field_attrib ( attrib_type, buffer)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -104,7 +104,7 @@ h5b_has_field_attrib ( TRY (ret_value = hdf5_attribute_exists ( f->b->field_gid, attrib_name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_ssize_t @@ -120,7 +120,7 @@ h5b_get_num_field_attribs ( TRY (h5bpriv_open_field_group(f, field_name)); TRY (ret_value = hdf5_get_num_attribute (f->b->field_gid)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -153,7 +153,7 @@ h5b_get_field_attrib_info_by_idx ( attrib_idx, attrib_name, len_attrib_name, attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -181,7 +181,7 @@ h5b_get_field_attrib_info_by_name ( f->b->field_gid, attrib_name, attrib_type, attrib_nelem)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } static inline h5_err_t @@ -254,7 +254,7 @@ h5b_set_3d_field_coords ( coords, n_coords)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -289,7 +289,7 @@ h5b_get_3d_field_coords ( H5_FLOAT64, coords)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5b_io.c b/src/h5core/h5b_io.c index eea06bd..1286153 100644 --- a/src/h5core/h5b_io.c +++ b/src/h5core/h5b_io.c @@ -19,6 +19,8 @@ #include "h5core/h5_syscall.h" #include "h5core/h5b_io.h" +#include + /*! \ingroup h5_private @@ -38,7 +40,7 @@ h5bpriv_open_file ( h5b_fdata_t* b; if (f->b) - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); TRY (f->b = (h5b_fdata_t*)h5_calloc (1, sizeof (*f->b))); @@ -61,7 +63,7 @@ h5bpriv_open_file ( TRY (b->dcreate_prop = hdf5_create_property (H5P_DATASET_CREATE)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -92,7 +94,7 @@ h5bpriv_close_file ( TRY (h5_free (f->b)); f->b = NULL; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -104,7 +106,7 @@ _select_hyperslab_for_writing ( re-use existing hyperslab */ if ( f->b->shape >= 0 ) - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); h5b_fdata_t *b = f->b; h5b_partition_t *p = b->write_layout; @@ -189,7 +191,7 @@ _select_hyperslab_for_writing ( part_dims, NULL)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -213,7 +215,7 @@ _write_data ( hid_t type_file; TRY( type_file = hdf5_get_dataset_type (dataset) ); if ( type != type_file ) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Field '%s' already has type '%s' " @@ -241,7 +243,7 @@ _write_data ( TRY (h5priv_end_throttle (f)); TRY (hdf5_close_dataset (dataset)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -263,7 +265,7 @@ h5b_write_scalar_data ( TRY( _select_hyperslab_for_writing(f) ); TRY( _write_data(f, field_name, H5_BLOCKNAME_X, data, type) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -293,7 +295,7 @@ h5b_write_vector3d_data ( TRY( _write_data(f, field_name, H5_BLOCKNAME_Y, ydata, type) ); TRY( _write_data(f, field_name, H5_BLOCKNAME_Z, zdata, type) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -326,7 +328,7 @@ _select_hyperslab_for_reading ( TRY (rank = hdf5_get_dims_of_dataspace(b->diskshape, field_dims, NULL)); if (rank != 3) - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_INVAL, "H5Block dataset has bad rank '%d' instead" @@ -336,7 +338,7 @@ _select_hyperslab_for_reading ( 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_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_VIEW, "H5Block dataset has invalid view. " @@ -373,7 +375,7 @@ _select_hyperslab_for_reading ( (long long)part_dims[1], (long long)part_dims[0] ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -402,7 +404,7 @@ read_data ( TRY (h5priv_end_throttle (f)); TRY (hdf5_close_dataset(dataset)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -422,7 +424,7 @@ h5b_read_scalar_data ( TRY( h5bpriv_open_field_group(f, field_name) ); TRY( read_data(f, H5_BLOCKNAME_X, data, type) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -450,6 +452,6 @@ h5b_read_vector3d_data ( TRY( read_data(f, H5_BLOCKNAME_Y, ydata, type) ); TRY( read_data(f, H5_BLOCKNAME_Z, zdata, type) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5b_model.c b/src/h5core/h5b_model.c index 8520c29..c0def82 100644 --- a/src/h5core/h5b_model.c +++ b/src/h5core/h5b_model.c @@ -43,7 +43,7 @@ h5b_has_field_data ( H5_CORE_API_ENTER (h5_err_t, "f=%p", f); CHECK_FILEHANDLE (f); TRY (ret_value = hdf5_link_exists (f->step_gid, H5BLOCK_GROUPNAME_BLOCK)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } static void @@ -420,7 +420,7 @@ _dissolve_ghostzones ( } h5_free (p_begin); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -441,7 +441,7 @@ h5bpriv_release_hyperslab ( TRY (hdf5_close_dataspace(f->b->memshape)); f->b->memshape = -1; } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -454,11 +454,11 @@ 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_PRIV_API_LEAVE (h5_error( + H5_LEAVE (h5_error( H5_ERR_INVAL, "Time step does not contain H5Block data!")); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -476,7 +476,7 @@ _create_block_group ( TRY (f->b->block_gid = hdf5_create_group( f->step_gid, H5BLOCK_GROUPNAME_BLOCK) ); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -496,7 +496,7 @@ h5bpriv_open_field_group ( H5_ERR_INVAL, "Field '%s' does not exist!", name2); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -522,7 +522,7 @@ h5bpriv_create_field_group ( TRY (b->field_gid = hdf5_create_group (b->block_gid, name2)); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_int64_t @@ -609,7 +609,7 @@ h5b_3d_set_view ( TRY( h5bpriv_release_hyperslab(f) ); b->have_layout = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -641,7 +641,7 @@ h5b_3d_get_view ( *k_start = p->k_start; *k_end = p->k_end; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -673,7 +673,7 @@ h5b_3d_get_reduced_view ( *k_start = p->k_start; *k_end = p->k_end; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -702,7 +702,7 @@ h5b_3d_set_chunk ( TRY (hdf5_set_chunk_property (f->b->dcreate_prop, 1, dims)); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -742,7 +742,7 @@ h5b_3d_get_chunk ( (long long)hdims[1], (long long)hdims[2] ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef PARALLEL_IO @@ -761,7 +761,7 @@ h5b_3d_set_grid ( (long long unsigned)j, (long long unsigned)k); if (i*j*k != f->nprocs) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error(H5_ERR_INVAL, "Grid dimensions (%lld,%lld,%lld) do not multiply " "out to %d MPI processors!", @@ -782,7 +782,7 @@ h5b_3d_set_grid ( f->b->have_grid = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -798,7 +798,7 @@ 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_CORE_API_LEAVE ( + H5_LEAVE ( h5_error(H5_ERR_INVAL, "Grid dimensions have not been set!")); @@ -807,7 +807,7 @@ h5b_3d_get_grid_coords ( *k = coords[0]; *j = coords[1]; *i = coords[2]; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -825,7 +825,7 @@ h5b_3d_set_dims ( (long long unsigned)j, (long long unsigned)k); if ( !f->b->have_grid ) - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error(H5_ERR_INVAL, "Grid dimensions have not been set!")); @@ -839,7 +839,7 @@ h5b_3d_set_dims ( dims[1] != check_dims[1] || dims[2] != check_dims[2] ) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error(H5_ERR_INVAL, "[%d] Block dimensions do not agree: " "(%lld,%lld,%lld) != (%lld,%lld,%lld)!", @@ -872,7 +872,7 @@ h5b_3d_set_dims ( b->have_layout = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -892,11 +892,11 @@ h5b_3d_set_halo ( (long long unsigned)k); if ( !f->b->have_grid ) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error(H5_ERR_INVAL, "Grid dimensions have not been set!")); } else if ( !f->b->have_layout ) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error(H5_ERR_INVAL, "Block dimensions for grid have not been set!")); } @@ -909,7 +909,7 @@ h5b_3d_set_halo ( b->user_layout->k_start -= k; b->user_layout->k_end += k; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_ssize_t @@ -922,7 +922,7 @@ h5b_get_num_fields ( TRY (h5bpriv_open_block_group(f)); TRY (ret_value = hdf5_get_num_objs_in_group (f->b->block_gid)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -938,7 +938,7 @@ h5b_has_field ( const char* path[] = { H5BLOCK_GROUPNAME_BLOCK, name }; TRY (ret_value = h5priv_link_exists_(f->step_gid, path, 2)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -991,7 +991,7 @@ h5b_get_field_info_by_name ( TRY (hdf5_close_dataspace (dataspace_id)); TRY (hdf5_close_dataset (dataset_id)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -1026,6 +1026,6 @@ h5b_get_field_info ( TRY (h5b_get_field_info_by_name ( (h5_file_t)f, name, field_rank, field_dims, elem_rank, type)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_adjacencies.c b/src/h5core/h5t_adjacencies.c index f8a9dd7..01da47b 100644 --- a/src/h5core/h5t_adjacencies.c +++ b/src/h5core/h5t_adjacencies.c @@ -27,7 +27,7 @@ h5t_get_adjacencies ( "m=%p, entity_id=%llu, dim=%d, list=%p", m, (long long unsigned)entity_id, dim, list); TRY (ret_value = h5tpriv_get_adjacencies (m, entity_id, dim, list)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -38,7 +38,7 @@ h5t_release_list_of_adjacencies ( H5_CORE_API_ENTER (h5_err_t, "m=%p, list=%p", m, list); UNUSED_ARGUMENT (m); TRY (ret_value = h5priv_free_loc_idlist (list)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -55,5 +55,5 @@ h5t_find_te2 ( (long long)elem_idx, retval); TRY (ret_value = h5tpriv_find_te2 (m,face_idx,elem_idx,retval)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } diff --git a/src/h5core/h5t_io.c b/src/h5core/h5t_io.c index 7f55aab..e5b8c0e 100644 --- a/src/h5core/h5t_io.c +++ b/src/h5core/h5t_io.c @@ -47,17 +47,6 @@ int dont_use_parmetis = 0; #include -//TODO this is a bugfix remove after xfer_prop fix has been done! -void -set_xfer_prop_to (const h5_file_p file, hid_t prop) { - file->props->xfer_prop = prop; -} - -void -set_xfer_prop_to2 (h5t_mesh_t* const m, hid_t prop) { - m->f->props->xfer_prop = prop; -} - static hid_t open_space_all ( h5t_mesh_t* const m, @@ -147,16 +136,16 @@ write_vertices ( m->first_b_vtx, m->num_leaf_levels, 1)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef WITH_PARALLEL_H5GRID -h5_err_t +static h5_err_t add_chunk_to_list ( - h5t_mesh_t* const m, - h5_loc_idxlist_t** list, - h5_oct_idx_t oct_idx - ) { + h5t_mesh_t* const m, + h5_loc_idxlist_t** list, + h5_oct_idx_t oct_idx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, list=%p, oct_idx=%d", m, list, oct_idx); h5t_oct_userdata_t* userdata; TRY (H5t_get_userdata_r (m->octree, oct_idx,(void **) &userdata)); @@ -165,20 +154,26 @@ add_chunk_to_list ( h5priv_search_in_loc_idxlist(list, (h5_loc_idx_t)userdata->idx[i]); } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -int compare_chk_idx(const void *p_a, const void *p_b) -{ -return ((*(h5_chk_idx_t*)p_a) - (*(h5_chk_idx_t*)p_b)); + +#if 0 +static int +compare_chk_idx ( + const void *p_a, + const void *p_b + ) { + return ((*(h5_chk_idx_t*)p_a) - (*(h5_chk_idx_t*)p_b)); } +#endif h5_err_t h5tpriv_get_list_of_chunks_to_write ( - h5t_mesh_t* const m, - h5_chk_idx_t** list, - int* counter - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p list=%p, counter=%p", m, list, counter); + h5t_mesh_t* const m, + h5_chk_idx_t** list, + int* counter + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p list=%p, counter=%p", m, list, counter); h5_chk_idx_t num_chunks = m->chunks->curr_idx + 1; // Is that ok? yes if update is correct int rank = m->f->myproc; @@ -203,18 +198,18 @@ h5tpriv_get_list_of_chunks_to_write ( if (size_list < *counter) { h5_debug ("Overflow of list_of_chunks"); - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t exchange_g2l_vtx_map ( - h5t_mesh_t* const m, - h5_idxmap_t* map, - h5_glb_idx_t** range, - h5_glb_idx_t** glb_vtx - ) { + h5t_mesh_t* const m, + h5_idxmap_t* map, + h5_glb_idx_t** range, + h5_glb_idx_t** glb_vtx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p map=%p, range=%p, glb_vtx=%p", m, map, range, glb_vtx); // alloc/get range TRY (*range = h5_calloc (m->f->nprocs + 1, sizeof (**range))); @@ -245,21 +240,30 @@ exchange_g2l_vtx_map ( recvdisp, MPI_LONG, m->f->props->comm)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif -int sort_glb_idx(const void *p_a, const void *p_b) -{ - return (*(h5_glb_idx_t*)p_a) - (*(h5_glb_idx_t*)p_b); +static int +sort_glb_idx ( + const void *p_a, + const void *p_b + ) { + return (*(h5_glb_idx_t*)p_a) - (*(h5_glb_idx_t*)p_b); } /* * instead of bsearch it returns the first element that fulfills compare(key,element) == 0 in an unsorted array * we don't want to sort array since it's also containing a permutation */ -void * linsearch (const void *key, void *array, size_t count, size_t size, - comparison_fn_t compare) { +void* +linsearch ( + const void *key, + void *array, + size_t count, + size_t size, + comparison_fn_t compare + ) { void* pointer = array; for (int i = 0; i < count; i++) { if (compare.compare(key,pointer) == 0) { @@ -271,17 +275,17 @@ void * linsearch (const void *key, void *array, size_t count, size_t size, return NULL; } -h5_err_t +static h5_err_t remove_item_from_idxmap ( - h5_idxmap_t* map, - int item_idx - ) { + h5_idxmap_t* map, + int item_idx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "map=%p, item_idx=%d", map, item_idx); assert(item_idx < map->num_items); memmove(&map->items[item_idx], &map->items[item_idx + 1], (map->num_items - 1 - item_idx) * sizeof (*map->items)); map->num_items--; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if defined(WITH_PARALLEL_H5GRID) @@ -291,14 +295,14 @@ remove_item_from_idxmap ( */ static h5_err_t check_multiple_vtx_writes ( - h5t_mesh_t* const m, - h5_idxmap_t* map, - h5_glb_idx_t* range, - h5_glb_idx_t* glb_vtx - ) { + h5t_mesh_t* const m, + h5_idxmap_t* map, + h5_glb_idx_t* range, + h5_glb_idx_t* glb_vtx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p map=%p, range=%p, glb_vtx=%p", m, map, range, glb_vtx); if (m->f->myproc == 0) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } h5_glb_idx_t num_glb_vtx = range[m->f->myproc]; // sort glb_vtx up to my vtx @@ -318,26 +322,26 @@ check_multiple_vtx_writes ( i--; // same position should be check again } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif h5_int32_t -find_proc_to_write ( - h5t_mesh_t* const m, - h5_loc_idx_t elem_idx - ) { - H5_PRIV_FUNC_ENTER (int, "m=%p ", m); +h5priv_find_proc_to_write ( + h5t_mesh_t* const m, + h5_loc_idx_t elem_idx + ) { + H5_PRIV_API_ENTER (int, "m=%p ", m); #ifdef WITH_PARALLEL_H5GRID h5_glb_idx_t glb_idx = h5tpriv_get_loc_elem_glb_idx (m, elem_idx); for (int i = 0; i < m->chunks->num_alloc; i++) { if ( glb_idx >= m->chunks->chunks[i].elem && glb_idx < m->chunks->chunks[i].elem + m->chunks->chunks[i].num_elems) { - H5_PRIV_FUNC_LEAVE (H5t_get_proc (m->octree, m->chunks->chunks[i].oct_idx)); + H5_LEAVE (H5t_get_proc (m->octree, m->chunks->chunks[i].oct_idx)); } } #endif - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef WITH_PARALLEL_H5GRID @@ -350,9 +354,9 @@ find_proc_to_write ( */ static h5_err_t get_map_vertices_write ( - h5t_mesh_t* const m, - h5_idxmap_t* map - ) { + h5t_mesh_t* const m, + h5_idxmap_t* map + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, map=%p", m, map); h5_chk_idx_t* list_of_chunks; int num_chunks = 0; @@ -409,7 +413,7 @@ get_map_vertices_write ( TRY (h5_free (range)); TRY (h5_free (glb_vtx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } //TODO maybe use ifdef to have name without _chk @@ -452,7 +456,6 @@ write_vertices_chk ( seloper = H5S_SELECT_OR; } - // create diskspace and select subset hsize_t num_glb_vertices = m->num_glb_vertices[m->num_leaf_levels-1]; m->dsinfo_vertices.dims[0] = num_glb_vertices; @@ -517,7 +520,7 @@ write_vertices_chk ( TRY (hdf5_close_dataset (dset_id)); m->f->empty = 0; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -525,7 +528,7 @@ write_elems ( h5t_mesh_t* const m ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); - H5_PRIV_FUNC_RETURN (h5_error_not_implemented ()); + H5_RETURN (h5_error_not_implemented ()); } #else @@ -594,7 +597,7 @@ write_elems ( 1)); // release mem TRY (h5_free (glb_elems)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif #ifdef WITH_PARALLEL_H5GRID @@ -714,13 +717,13 @@ write_elems_chk ( TRY (hdf5_close_dataspace (dspace_id)); TRY (hdf5_close_dataspace (mspace_id)); TRY (hdf5_close_dataset (dset_id)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -hid_t +static hid_t set_chk_memspace ( - h5t_mesh_t* m, - hid_t dataspace_id) { + h5t_mesh_t* m, + hid_t dataspace_id) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, dataspace_id=%lld", m, (long long int)dataspace_id); @@ -744,14 +747,14 @@ set_chk_memspace ( &hstart, &hstride, &hcount, NULL)); } - H5_PRIV_FUNC_RETURN (mspace_id); + H5_RETURN (mspace_id); } -hid_t +static hid_t set_chk_diskspace ( - h5t_mesh_t* m, - hid_t dspace_id - ) { + h5t_mesh_t* m, + hid_t dspace_id + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, dataspace_id=%lld", m, (long long int)dspace_id); @@ -775,12 +778,12 @@ set_chk_diskspace ( &hstart, &hstride, &hcount, NULL)); } - H5_PRIV_FUNC_RETURN (dspace_id); + H5_RETURN (dspace_id); } -h5_err_t +static h5_err_t write_chunks ( - h5t_mesh_t* const m + h5t_mesh_t* const m ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); m->dsinfo_chunks.dims[0] = m->chunks->num_alloc; @@ -819,13 +822,14 @@ write_chunks ( m->chunks->num_levels, 1)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -hid_t +static hid_t set_oct_memspace ( - h5t_mesh_t* m, - hid_t dataspace_id) { + h5t_mesh_t* m, + hid_t dataspace_id + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, dataspace_id=%lld", m, (long long int)dataspace_id); @@ -849,14 +853,14 @@ set_oct_memspace ( &hstart, &hstride, &hcount, NULL)); } - H5_PRIV_FUNC_RETURN (mspace_id); + H5_RETURN (mspace_id); } -hid_t +static hid_t set_oct_diskspace ( - h5t_mesh_t* m, - hid_t dspace_id - ) { + h5t_mesh_t* m, + hid_t dspace_id + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, dataspace_id=%lld", m, (long long int)dspace_id); @@ -880,12 +884,12 @@ set_oct_diskspace ( &hstart, &hstride, &hcount, NULL)); } - H5_PRIV_FUNC_RETURN (dspace_id); + H5_RETURN (dspace_id); } -h5_err_t +static h5_err_t write_octree ( - h5t_mesh_t* const m + h5t_mesh_t* const m ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); @@ -948,14 +952,13 @@ write_octree ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } - -hid_t +static hid_t set_weight_memspace ( - h5t_mesh_t* m, - hid_t dataspace_id) { + h5t_mesh_t* m, + hid_t dataspace_id) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, dataspace_id=%lld", m, (long long int)dataspace_id); @@ -979,14 +982,14 @@ set_weight_memspace ( &hstart, &hstride, &hcount, NULL)); } - H5_PRIV_FUNC_RETURN (mspace_id); + H5_RETURN (mspace_id); } -hid_t +static hid_t set_weight_diskspace ( - h5t_mesh_t* m, - hid_t dspace_id - ) { + h5t_mesh_t* m, + hid_t dspace_id + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, dataspace_id=%lld", m, (long long int)dspace_id); @@ -1010,16 +1013,16 @@ set_weight_diskspace ( &hstart, &hstride, &hcount, NULL)); } - H5_PRIV_FUNC_RETURN (dspace_id); + H5_RETURN (dspace_id); } /* * weights is an array that stores the element weights. c weights per element with n elements, gives a size of c*n. * where the weights of an element are stored contiguosly. i.e. first weight of second elem is at weights[c*1]. */ -h5_err_t +static h5_err_t write_weights ( - h5t_mesh_t* const m + h5t_mesh_t* const m ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); @@ -1042,9 +1045,10 @@ write_weights ( 1, 1)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif + h5_err_t h5tpriv_write_mesh ( h5t_mesh_t* const m @@ -1088,7 +1092,7 @@ h5tpriv_write_mesh ( } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } // ANCHOR WRITE /* @@ -1153,7 +1157,7 @@ read_vertices ( TRY (hdf5_close_dataspace (mspace_id)); TRY (hdf5_close_dataset (dset_id)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -1197,7 +1201,7 @@ read_elems ( TRY (hdf5_close_dataspace (mspace_id)); TRY (hdf5_close_dataset (dset_id)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -1212,7 +1216,7 @@ read_elems ( Step 2: Handle ghost- and border cells Step 3: Read vertices */ -h5_err_t +static h5_err_t part_kway ( h5t_mesh_t* const m, h5_glb_elem_t** glb_elems @@ -1313,7 +1317,7 @@ part_kway ( &m->f->props->comm ); if (rc != METIS_OK) { - H5_PRIV_FUNC_LEAVE( + H5_LEAVE( h5_error (H5_ERR, "ParMETIS failed")); } TRY (h5_free (vtxdist)); @@ -1417,7 +1421,7 @@ part_kway ( TRY (h5_free (elems)); *glb_elems = recvbuf; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -1432,14 +1436,14 @@ part_kway ( the same cell to multiple procs) 6. scatter border cells with alltoallv */ -h5_err_t +static h5_err_t exchange_ghost_cells ( h5t_mesh_t* const m, h5_glb_elem_t* glb_elems, h5_glb_elem_t** ghost_elems, size_t* num_ghost_elems ) { - H5_PRIV_API_ENTER (h5_err_t, "m=%p, ghost_elems=%p", m, ghost_elems); + H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, ghost_elems=%p", m, ghost_elems); int* sendcounts; int* senddispls; int* recvcounts; @@ -1584,7 +1588,7 @@ exchange_ghost_cells ( *ghost_elems = recvbuf; *num_ghost_elems = num_loc_ghost_elems; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -1593,7 +1597,7 @@ h5tpriv_read_mesh ( h5t_mesh_t* const m ) { H5_PRIV_API_ENTER (h5_err_t, "m=%p", m); - h5_glb_elem_t* glb_elems; + h5_glb_elem_t* glb_elems = NULL; TRY (part_kway (m, &glb_elems)); h5_loc_idx_t num_interior_elems = m->num_interior_elems[0]; @@ -1673,7 +1677,7 @@ h5tpriv_read_mesh ( TRY (h5tpriv_init_elem_flags (m, 0, num_interior_elems+num_ghost_elems)); TRY (h5tpriv_update_internal_structs (m, 0)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #else @@ -1706,7 +1710,7 @@ h5tpriv_read_mesh ( TRY (h5tpriv_init_elem_flags (m, 0, num_interior_elems)); TRY (h5_free (glb_elems)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -1789,12 +1793,12 @@ read_octree ( - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t read_weights ( - h5t_mesh_t* m - ) { + h5t_mesh_t* m + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); hid_t dset_id; TRY (dset_id = hdf5_open_dataset_by_name (m->mesh_gid, m->dsinfo_weights.name)); @@ -1838,7 +1842,7 @@ read_weights ( TRY (hdf5_close_dataspace (dspace_id)); TRY (hdf5_close_dataspace (mspace_id)); TRY (hdf5_close_dataset (dset_id)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -1891,7 +1895,7 @@ read_chunks ( TRY (hdf5_close_dataspace (mspace_id)); TRY (hdf5_close_dataset (dset_id)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -1902,12 +1906,12 @@ read_chunks ( static h5_err_t get_weights_of_octant ( - h5t_mesh_t* const m, - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - double factor, - idx_t* weights - ) { + h5t_mesh_t* const m, + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + double factor, + idx_t* weights + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, octree=%p, oct_idx=%d, factor=%4.4f, weights=%p", m, octree, oct_idx, factor, weights); @@ -1931,16 +1935,16 @@ get_weights_of_octant ( while ((oct_idx = H5t_get_parent (octree, oct_idx)) != -1) { TRY (get_weights_of_octant (m, octree, oct_idx, factor/((double) NUM_OCTANTS), weights)); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t +static h5_err_t calc_weights_oct_leaflevel ( - h5t_mesh_t* const m, - idx_t** weights, - h5_oct_idx_t** new_numbering, - h5_oct_idx_t* num_tot_leaf_oct - ) { + h5t_mesh_t* const m, + idx_t** weights, + h5_oct_idx_t** new_numbering, + h5_oct_idx_t* num_tot_leaf_oct + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, weights=%p, new_numbering=%p", m, weights, new_numbering); int size = m->f->nprocs; int rank = m->f->myproc; @@ -1993,15 +1997,16 @@ calc_weights_oct_leaflevel ( H5t_end_iterate_oct (iter); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t + +static h5_err_t distribute_octree_parmetis ( - h5t_mesh_t* const m, - idx_t* weights, - h5_oct_idx_t* new_numbering, - h5_oct_idx_t num_tot_leaf_oct - ) { + h5t_mesh_t* const m, + idx_t* weights, + h5_oct_idx_t* new_numbering, + h5_oct_idx_t num_tot_leaf_oct + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, weights=%p, new_numbering=%p", m, weights, new_numbering); if (num_tot_leaf_oct < m->f->nprocs) { @@ -2057,13 +2062,23 @@ distribute_octree_parmetis ( h5_oct_idx_t* ancestor_of_neigh = NULL; h5_oct_idx_t num_anc_of_neigh; - // plot_octants (m->octree); + // h5priv_plot_octants (m->octree); idx_t i; idx_t counter = 0; for (i = 0; i < num_interior_oct; i++) { - TRY (H5t_get_neighbors (m->octree, new_numbering[start + i], &neighbors, &num_neigh, &ancestor_of_neigh, &num_anc_of_neigh, 1, m->leaf_level)); + TRY ( + H5t_get_neighbors ( + m->octree, + new_numbering[start + i], + &neighbors, + &num_neigh, + &ancestor_of_neigh, + &num_anc_of_neigh, + 1, + m->leaf_level)); if (counter + num_neigh >= num_alloc_adj) { - adjncy = realloc (adjncy, (num_alloc_adj + counter + num_neigh) * sizeof(*adjncy)); // WARNING may alloc too much mem (minimal would be counter + num_neigh) + // WARNING may alloc too much mem (minimal would be counter + num_neigh) + adjncy = realloc (adjncy, (num_alloc_adj + counter + num_neigh) * sizeof(*adjncy)); } xadj[i+1] = xadj[i] + num_neigh; #if !defined(NDEBUG) @@ -2086,7 +2101,7 @@ distribute_octree_parmetis ( } } if (found == 0) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } } } @@ -2135,7 +2150,7 @@ distribute_octree_parmetis ( &m->f->props->comm ); if (rc != METIS_OK) { - H5_PRIV_FUNC_LEAVE( + H5_LEAVE( h5_error (H5_ERR, "ParMETIS failed")); } @@ -2198,26 +2213,6 @@ distribute_octree_parmetis ( h5_float64_t loc_max = newbb[preferred_direction + 3]; h5_float64_t loc_mid = (loc_min + loc_max) / 2.0; glb_part[i] = (int) ((loc_mid - glb_min)/slice_length); - -// int lower_slice = (int) ((loc_min-glb_min)/slice_length); -// int higher_slice = (int) ((loc_max-glb_min)/slice_length); -// if (!(lower_slice == higher_slice || lower_slice + 1 == higher_slice)) { -// printf (" glb_min %4.4f glb_max %4.4f slice_length %4.4f loc_min %4.4f loc_max %4.4f lower_slice %d higher_slice %d", -// glb_min, glb_max, slice_length, loc_min, loc_max, lower_slice, higher_slice); -// -// assert (lower_slice == higher_slice || lower_slice + 1 == higher_slice); -// -// } -// if (lower_slice == higher_slice) { -// glb_part[i] = lower_slice; -// } else if ( higher_slice *slice_length - (loc_min - glb_min) >= (loc_max-glb_min) - higher_slice *slice_length) { -// // belongs to lower_slice -// glb_part[i] = lower_slice; -// -// } else {// belongs to higher_slice -// glb_part[i] = higher_slice; -// } - } } assert (dont_use_parmetis > -1 && dont_use_parmetis <3); @@ -2228,7 +2223,9 @@ distribute_octree_parmetis ( h5_oct_idx_t parent = oct_idx; while ((parent = H5t_get_parent (m->octree, parent)) != -1) { if (H5t_get_children(m->octree, parent) == oct_idx) { - // oct_idx is the first children - so set the proc of the parent to the same as the oct_idx + // oct_idx is the first children - so set + // the proc of the parent to the same as + // the oct_idx TRY (H5t_set_proc_int (m->octree, parent, glb_part[i])); oct_idx = parent; } else { @@ -2243,93 +2240,35 @@ distribute_octree_parmetis ( TRY (h5_free (vtxdist)); TRY (h5_free (glb_part)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t +static h5_err_t add_oct_children_to_list ( - h5t_mesh_t* const m, - h5_loc_idxlist_t** oct_list, - h5_oct_idx_t oct_idx) { + h5t_mesh_t* const m, + h5_loc_idxlist_t** oct_list, + h5_oct_idx_t oct_idx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p list=%p, oct_idx=%d", m, oct_list, oct_idx); assert (oct_idx > 0); // otherwise we add the whole octree! h5_oct_idx_t children = H5t_get_children (m->octree, oct_idx); if (children == -1 ) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } // get siblings h5_oct_idx_t sibling_idx = H5t_get_sibling (m->octree, children); for (int i = 0; i < NUM_OCTANTS; i++) { h5priv_search_in_loc_idxlist(oct_list,(h5_loc_idx_t) sibling_idx + i); - TRY (add_oct_children_to_list (m, oct_list,(h5_loc_idx_t) sibling_idx + i)); // TODO it may could be faster to do this + TRY (add_oct_children_to_list (m, oct_list,(h5_loc_idx_t) sibling_idx + i)); + // TODO it may could be faster to do this // is a second loop because adding elems just after each other could be beneficial -> maybe extend // insert to multiple insert... } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } - -//h5_err_t -//h5tpriv_get_list_of_chunks_to_read ( -// h5t_mesh_t* const m, -// h5_chk_idx_t** list, -// int* counter -// ) { -// H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p list=%p, counter=%p", m, list, counter); -// -// int rank = m->f->myproc; -// int size_list = m->chunks->curr_idx + 1; -// TRY ( *list = h5_calloc (size_list + 1, sizeof (**list))); // +1 to be on save side for accesses -// *counter = 0; -// -// // go through octree level, get own chunks and parent chunks -// h5t_oct_iterator_t* iter = NULL; -// TRY (H5t_init_oct_iterator (m->octree, &iter, m->leaf_level)); -// -// h5_oct_idx_t oct_idx = -1; -// while ((oct_idx = H5t_iterate_oct (iter)) != -1) { -// if (H5t_get_proc (m->octree, oct_idx) == rank) { -// add_chunk_to_list (m, *list, counter, oct_idx); -// h5_oct_idx_t parent = oct_idx; -// // add parent chunks -// while ((parent = H5t_get_parent (m->octree, parent)) != -1) { -// add_chunk_to_list (m, *list, counter, parent); -// } -// h5_oct_idx_t* neigh = NULL; -// h5_oct_idx_t* anc = NULL; -// h5_oct_idx_t num_neigh = 0; -// h5_oct_idx_t num_anc = 0; -// -// // get neighboring chunks as well -// TRY (H5t_get_neighbors ( -// m->octree, -// oct_idx, -// &neigh, -// &num_neigh, -// &anc, -// &num_anc, -// 3, -// m->leaf_level)); -// for (int i = 0; i < num_neigh; i++) { -// add_chunk_to_list (m, *list, counter, neigh[i]); -// } -// for (int i = 0; i < num_anc; i++) { -// add_chunk_to_list (m, *list, counter, anc[i]); -// // TODO get all children of ancestor on level 1 and ad them as well -// } -// } -// } -// -// TRY (H5t_end_iterate_oct (iter)); -// if (size_list < *counter) { -// h5_debug ("Overflow of list_of_chunks"); -// H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); -// } -// qsort (*list, *counter, sizeof (**list), compare_chk_idx); -// H5_PRIV_FUNC_RETURN (H5_SUCCESS); -//} /* Idea: we need to get all octants that belong to this proc including all their parent and children. (octants that dont have a userlevel should not be added) @@ -2338,11 +2277,11 @@ add_oct_children_to_list ( */ h5_err_t h5tpriv_get_list_of_chunks_to_read ( - h5t_mesh_t* const m, - h5_chk_idx_t** list, - int* counter - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p list=%p, counter=%p", m, list, counter); + h5t_mesh_t* const m, + h5_chk_idx_t** list, + int* counter + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p list=%p, counter=%p", m, list, counter); int rank = m->f->myproc; int size_list = m->chunks->curr_idx + 1; TRY ( *list = h5_calloc (size_list + 1, sizeof (**list))); // +1 to be on save side for accesses @@ -2372,11 +2311,15 @@ h5tpriv_get_list_of_chunks_to_read ( parent_idx = parent; while ((parent_idx = H5t_get_parent (m->octree, parent_idx)) != -1) { if (H5t_get_userlevel(m->octree, parent) != 0) { - break; // parent_idx still has a level -> so need parent needs to be added + // parent_idx still has a level -> + //so need parent needs to be added + break; } } if (parent_idx == -1) { - break; // parent_idx is -1 so all parents don't have a level anymore -> don't add + // parent_idx is -1 so all parents don't + // have a level anymore -> don't add + break; } } if (parent_idx != -1) { @@ -2419,11 +2362,6 @@ h5tpriv_get_list_of_chunks_to_read ( // add children TRY (add_oct_children_to_list (m, &neigh_oct_list, (h5_loc_idx_t)neigh[i])); } -// for (int i = 0; i < num_anc; i++) { -// h5priv_search_in_loc_idxlist(&neigh_oct_list, anc[i]); -// // add children -// TRY (add_oct_children_to_list (m, &neigh_oct_list, anc[i])); -// } // add octants to chunk_list add_chunk_to_list (m, &loc_list,(h5_oct_idx_t) oct_list->items[i]); } @@ -2444,23 +2382,22 @@ h5tpriv_get_list_of_chunks_to_read ( TRY (h5priv_free_loc_idxlist (&neigh_oct_list)); if (size_list < *counter) { h5_debug ("Overflow of list_of_chunks"); - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * returns a list of processors for assigning proc to each element */ - -h5_err_t +static h5_err_t get_list_of_proc ( - h5t_mesh_t* const m, - h5_int32_t* my_procs, - h5_chk_idx_t* list, - int num_chunks - ) { + h5t_mesh_t* const m, + h5_int32_t* my_procs, + h5_chk_idx_t* list, + int num_chunks + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, my_procs=%p, list=%p", m, my_procs, list); int counter = 0; for (int i = 0; i < num_chunks; i++) { @@ -2473,87 +2410,35 @@ get_list_of_proc ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -// for (hsize_t i = 0; i < map->num_items; i++) { -// hsize_t hstart = map->items[i].glb_idx; -// hsize_t hcount = 1; -// while (map->items[i].glb_idx+1 == map->items[i+1].glb_idx && -// i < map->num_items) { -// i++; hcount++; -// } -// TRY (hdf5_select_hyperslab_of_dataspace ( -// dspace_id, -// seloper, -// &hstart, &hstride, &hcount, -// NULL)); -// seloper = H5S_SELECT_OR; -// } -h5_lvl_idx_t + +static h5_lvl_idx_t get_level_of_chk_idx ( - h5t_mesh_t* const m, - h5_chk_idx_t chk_idx - ) { + h5t_mesh_t* const m, + h5_chk_idx_t chk_idx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, chk_idx=%d", m, chk_idx); assert (chk_idx > -1); int nbr_chunks = m->chunks->num_chunks_p_level[0]; for (int i = 0; i < m->chunks->num_levels; i++) { if (chk_idx < nbr_chunks) { - H5_PRIV_FUNC_LEAVE (i); + H5_LEAVE (i); } else { if (i+1 < m->chunks->num_levels) { nbr_chunks += m->chunks->num_chunks_p_level[i + 1]; } } } - H5_PRIV_FUNC_RETURN (-2); - // should be much simpler then that! -// // get oct_idx -// h5_oct_idx_t oct_idx = m->chunks->chunks[chk_idx].oct_idx; -// void* pointer; -// -// TRY (H5t_get_userdata_r (m->octree, oct_idx, &pointer)); //TRY gives unresolved?? -// h5t_oct_userdata_t* userdata = (h5t_oct_userdata_t*)pointer; -// int i = 0; -// for (; i < OCT_USERDATA_SIZE; i++) { -// if (userdata->idx[i] == chk_idx) { -// break; -// } -// } -// if (i >= OCT_USERDATA_SIZE) { -// H5_PRIV_FUNC_LEAVE ( -// h5_error (H5_ERR_INTERNAL, "Chunk %d should be in octant %d but it was not found", chk_idx, oct_idx)); -// } -// -// int position = 0; -// h5_oct_level_t usr_lvl = H5t_get_userlevel (m->octree, oct_idx); -// h5_lvl_idx_t level = -1; -// while (i >= 0) { -// while (position < OCT_USERLEV_LENGTH) { -// if ((usr_lvl & (1 << position)) == (1 << position)) { -// i--; -// break; -// } -// } -// position++; -// } -// -// if (i != -1 || position == OCT_USERLEV_LENGTH) { -// H5_PRIV_FUNC_LEAVE ( -// h5_error (H5_ERR_INTERNAL, "Userlevel in octant %d are not set correctly. Userlevel: %d", oct_idx, usr_lvl)); -// } else { -// level = position - 1; -// } - - + H5_RETURN (-2); } -h5_err_t +static h5_err_t read_chunked_elements ( - h5t_mesh_t* const m, - h5_glb_elem_t** glb_elems, - h5_int32_t** my_procs - ) { + h5t_mesh_t* const m, + h5_glb_elem_t** glb_elems, + h5_int32_t** my_procs + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); // find chunks to read h5_chk_idx_t* list_of_chunks = NULL; @@ -2606,7 +2491,8 @@ read_chunked_elements ( hstart = (hsize_t)m->chunks->chunks[list_of_chunks[i]].elem; hcount = (hsize_t)m->chunks->chunks[list_of_chunks[i]].num_elems; while (i + 1 < num_interior_chunks && - hstart + hcount == m->chunks->chunks[list_of_chunks[i+1]].elem) { // WARNING make sure list has one free element in the back otherwise seg fault + hstart + hcount == m->chunks->chunks[list_of_chunks[i+1]].elem) { + // WARNING make sure list has one free element in the back otherwise seg fault hcount += (hsize_t)m->chunks->chunks[list_of_chunks[i+1]].num_elems; i++; } @@ -2664,7 +2550,7 @@ read_chunked_elements ( #endif - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -2700,8 +2586,8 @@ h5tpriv_read_chunked_mesh ( TRY (h5priv_mpi_barrier (m->f->props->comm)); m->timing.measure[m->timing.next_time++] = MPI_Wtime(); - h5_glb_elem_t* glb_elems; - h5_int32_t* my_procs; + h5_glb_elem_t* glb_elems = NULL; + h5_int32_t* my_procs = NULL; TRY (read_chunked_elements (m, &glb_elems, &my_procs)); TRY (h5priv_mpi_barrier (m->f->props->comm)); @@ -2771,7 +2657,7 @@ h5tpriv_read_chunked_mesh ( TRY (h5priv_mpi_barrier (m->f->props->comm)); m->timing.measure[m->timing.next_time++] = MPI_Wtime(); #endif - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -2823,7 +2709,7 @@ read_elems_part ( i++; hcount++; } if (hstart+hcount > num_glb_elems) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5FED, "invalid selection: start=%lld, count=%lld", @@ -2850,7 +2736,7 @@ read_elems_part ( TRY (hdf5_close_dataset (dset_id)); *glb_elems = elems; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -2930,7 +2816,6 @@ h5tpriv_read_mesh_part ( TRY (h5priv_mpi_barrier (m->f->props->comm)); // init update m->timing.measure[m->timing.next_time++] = MPI_Wtime(); #endif - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } - diff --git a/src/h5core/h5t_map.c b/src/h5core/h5t_map.c index b868859..fff6906 100644 --- a/src/h5core/h5t_map.c +++ b/src/h5core/h5t_map.c @@ -17,6 +17,8 @@ #include "private/h5t_model.h" #include "private/h5_mpi.h" +#include + /* Mapping of global to local id's: @@ -70,7 +72,7 @@ h5tpriv_sort_local_vertex_indices ( } indices[j] = idx; } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -95,7 +97,7 @@ h5tpriv_find_glb_idx_in_map ( if (loc_idx < 0) { // set to next position loc_idx = map->num_items; } - H5_CORE_API_RETURN (loc_idx); + H5_RETURN (loc_idx); } /*! @@ -112,12 +114,12 @@ h5t_map_global_vertex_idx2local ( // loc_idx is position in map h5_loc_idx_t loc_idx = h5priv_search_idxmap (&m->map_vertex_g2l, glb_idx); if (loc_idx < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5tpriv_error_global_id_nexist ("vertex", glb_idx)); } // loc_idx is position in m->vertices! TRY (ret_value = m->map_vertex_g2l.items[loc_idx].loc_idx); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -135,7 +137,7 @@ h5t_map_global_vertex_indices2local ( TRY (loc_indices[i] = h5t_map_global_vertex_idx2local (m, glb_indices[i])); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -158,13 +160,13 @@ h5t_map_glb_elem_idx2loc ( m, (long long)glb_idx); // global index is -1, if the cell is at the geometric border - if (glb_idx < 0) H5_CORE_API_LEAVE (-1); + if (glb_idx < 0) H5_LEAVE (-1); h5_loc_idx_t i = h5priv_search_idxmap (&m->map_elem_g2l, glb_idx); // global index >= 0 && negative result means: element is on other proc - if (i < 0) H5_CORE_API_LEAVE (-glb_idx-2); + if (i < 0) H5_LEAVE (-glb_idx-2); - H5_CORE_API_RETURN (m->map_elem_g2l.items[i].loc_idx); + H5_RETURN (m->map_elem_g2l.items[i].loc_idx); } @@ -185,7 +187,7 @@ h5t_map_glb_elem_indices2loc ( loc_indices++; glb_indices++; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -211,7 +213,7 @@ h5tpriv_rebuild_map_vertex_g2l ( m->map_vertex_g2l.num_items++; } h5priv_sort_idxmap (&m->map_vertex_g2l); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* rebuild mapping of global vertex indices to their local indices @@ -234,7 +236,7 @@ h5tpriv_rebuild_map_vertex_g2l_partial ( m->map_vertex_g2l.num_items++; } h5priv_sort_idxmap (&m->map_vertex_g2l); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* Get local vertex indices of entity given by it's local ID. @@ -260,7 +262,7 @@ h5t_get_loc_vertex_indices_of_entity ( case H5T_TYPE_TRIANGLE: dim = 2; break; case H5T_TYPE_TET: dim = 3; break; default: - H5_CORE_API_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (m, elem_idx); const h5t_ref_elem_t* ref_elem = m->ref_elem; @@ -269,7 +271,7 @@ h5t_get_loc_vertex_indices_of_entity ( int idx = h5tpriv_ref_elem_get_vertex_idx(m, dim, face_idx, i); vertex_indices[i] = indices[idx]; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -293,7 +295,7 @@ h5t_get_glb_vertex_indices_of_entity ( case H5T_TYPE_TRIANGLE: dim = 2; break; case H5T_TYPE_TET: dim = 3; break; default: - H5_CORE_API_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (m, elem_idx); const h5t_ref_elem_t* ref_elem = m->ref_elem; @@ -303,7 +305,7 @@ h5t_get_glb_vertex_indices_of_entity ( h5_loc_idx_t loc_idx = indices[idx]; vertex_indices[i] = m->vertices[loc_idx].idx; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -321,7 +323,7 @@ h5tpriv_get_loc_vtx_idx_of_vtx ( h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); TRY (ret_value = h5tpriv_get_loc_vtx_idx_of_vtx2 ( m, face_idx, elem_idx, vertex_index)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -338,7 +340,7 @@ h5tpriv_get_loc_vtx_idx_of_vtx2 ( (long long unsigned)elem_idx, vertex_indices); vertex_indices[0] = h5tpriv_get_loc_elem_vertex_idx (m, elem_idx, face_idx); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -360,7 +362,7 @@ h5t_get_loc_vertex_indices_of_edge ( TRY (ret_value = h5t_get_loc_vertex_indices_of_edge2 ( m, face_idx, elem_idx, vertex_indices)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } /*! @@ -390,7 +392,7 @@ h5t_get_loc_vertex_indices_of_edge2 ( vertex_indices[0] = indices[idx]; idx = h5tpriv_ref_elem_get_vertex_idx (m, 1, face_idx, 1); vertex_indices[1] = indices[idx]; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -408,7 +410,7 @@ h5t_get_loc_vertex_indices_of_triangle ( h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); TRY (ret_value = h5t_get_loc_vertex_indices_of_triangle2 ( m, face_idx, elem_idx, vertex_indices)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -433,7 +435,7 @@ h5t_get_loc_vertex_indices_of_triangle2 ( vertex_indices[1] = indices[idx]; idx = h5tpriv_ref_elem_get_vertex_idx (m, 2, face_idx, 2); vertex_indices[2] = indices[idx]; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -461,7 +463,7 @@ h5t_get_loc_vertex_indices_of_tet ( vertex_indices[2] = indices[idx]; idx = h5tpriv_ref_elem_get_vertex_idx (m, 3, 0, 3); vertex_indices[3] = indices[idx]; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef WITH_PARALLEL_H5GRID @@ -476,10 +478,10 @@ compare_glb_idx_oct (const void * p_a,const void* p_b) { */ h5_err_t h5priv_exchange_loc_list_to_glb ( - h5t_mesh_t* const m, - h5_glb_idxlist_t** glb_list - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, glb_list=%p", m, glb_list); + h5t_mesh_t* const m, + h5_glb_idxlist_t** glb_list + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, glb_list=%p", m, glb_list); int* num_elems = NULL; TRY (num_elems = h5_calloc (m->f->nprocs, sizeof (*num_elems))); @@ -498,7 +500,8 @@ 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_PRIV_FUNC_LEAVE (h5_error ( + 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], @@ -536,7 +539,7 @@ h5priv_exchange_loc_list_to_glb ( TRY (h5_free (num_elems)); TRY (h5_free (sendbuf)); TRY (h5_free (recvdispls)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -552,7 +555,7 @@ h5priv_find_idlist ( "list=%p, item=%llu", list, (long long unsigned)item); if (!list) { - H5_PRIV_API_LEAVE (-1); + H5_LEAVE (-1); } register size_t low = 0; register size_t mid; @@ -572,8 +575,8 @@ h5priv_find_idlist ( else if ( diff < 0 ) low = mid + 1; else - H5_PRIV_API_LEAVE (mid); // found + H5_LEAVE (mid); // found } - H5_PRIV_API_RETURN (-(low+1)); // not found + H5_RETURN (-(low+1)); // not found } diff --git a/src/h5core/h5t_model.c b/src/h5core/h5t_model.c index 62c3115..91af9a3 100644 --- a/src/h5core/h5t_model.c +++ b/src/h5core/h5t_model.c @@ -264,7 +264,7 @@ h5tpriv_init_mesh ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -283,7 +283,7 @@ release_elems ( TRY (h5_free (m->num_interior_leaf_elems)); m->num_interior_leaf_elems = NULL; TRY (h5_free (m->num_ghost_elems)); m->num_ghost_elems = NULL; TRY (h5_free (m->map_elem_g2l.items)); m->map_elem_g2l.items = NULL; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -297,7 +297,7 @@ release_vertices ( TRY (h5_free (m->map_vertex_g2l.items)); m->map_vertex_g2l.items = NULL; TRY (h5_free (m->first_b_vtx)); m->first_b_vtx = NULL; TRY (h5_free (m->num_b_vtx)); m->num_b_vtx = NULL; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -316,7 +316,7 @@ release_memory ( } #endif TRY (h5_free (m)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -364,7 +364,7 @@ write_timing ( m->timing.measure[26] - m->timing.measure[25]); fclose (file); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t set_timing_file ( @@ -373,7 +373,7 @@ set_timing_file ( ) { H5_CORE_API_ENTER (h5_err_t, "m=%p", m); m->timing.f = time_f; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t h5t_close_mesh ( @@ -386,7 +386,7 @@ h5t_close_mesh ( #endif // check if tagsets are still open if (m->mtagsets && m->mtagsets->num_items > 0) - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5FED, "Mesh cannot be closed: Mesh is referenced by open tagsets")); @@ -399,7 +399,7 @@ h5t_close_mesh ( TRY (write_timing (m)); #endif TRY (release_memory (m)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -410,7 +410,7 @@ h5t_set_level ( H5_CORE_API_ENTER (h5_err_t, "m=%p, level_id=%d", m, level_id); if ((level_id < 0) || (level_id >= m->num_leaf_levels)) - H5_CORE_API_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("Level", level_id)); + H5_LEAVE (HANDLE_H5_OUT_OF_RANGE_ERR ("Level", level_id)); h5_lvl_idx_t prev_level = m->leaf_level; m->leaf_level = level_id; @@ -418,7 +418,7 @@ h5t_set_level ( if (level_id >= m->num_loaded_levels) { TRY (h5tpriv_update_internal_structs (m, ++prev_level)); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -427,7 +427,7 @@ h5t_set_mesh_changed ( ) { H5_CORE_API_ENTER (h5_err_t, "m=%p",m); m->mesh_changed = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -438,14 +438,14 @@ h5tpriv_alloc_loc_vertices ( h5t_mesh_t* const m, const h5_size_t num ) { - H5_PRIV_FUNC_ENTER (h5_err_t, + H5_PRIV_API_ENTER (h5_err_t, "m=%p, num=%llu", m, (long long unsigned)num); ssize_t size = num * sizeof (m->vertices[0]); TRY (m->vertices = h5_alloc (m->vertices, size)); TRY (h5priv_grow_idxmap (&m->map_vertex_g2l, num)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -469,12 +469,12 @@ get_num_meshes ( h5_err_t exists; TRY (exists = hdf5_link_exists (f->root_gid, H5T_CONTAINER_GRPNAME)); - if (!exists) H5_CORE_API_LEAVE (0); + if (!exists) H5_LEAVE (0); TRY (topo_gid = hdf5_open_group (f->root_gid, H5T_CONTAINER_GRPNAME)); TRY (exists = hdf5_link_exists (topo_gid, grpname)); - if (!exists) H5_CORE_API_LEAVE (0); + if (!exists) H5_LEAVE (0); TRY (meshes_gid = hdf5_open_group (topo_gid, grpname)); h5_ssize_t num_meshes; @@ -482,7 +482,7 @@ get_num_meshes ( TRY (hdf5_close_group (meshes_gid) ); TRY (hdf5_close_group (topo_gid) ); - H5_CORE_API_RETURN (num_meshes); + H5_RETURN (num_meshes); } h5_ssize_t @@ -491,7 +491,7 @@ h5t_get_num_tetmeshes ( ) { H5_CORE_API_ENTER (h5_ssize_t, "f=%p", (h5_file_p)fh); TRY (ret_value = get_num_meshes (fh, TETRAHEDRAL_MESHES_GRPNAME)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_ssize_t @@ -500,7 +500,7 @@ h5t_get_num_trimeshes ( ) { H5_CORE_API_ENTER (h5_ssize_t, "f=%p", (h5_file_p)fh); TRY (ret_value = get_num_meshes (fh, TRIANGLE_MESHES_GRPNAME)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } /*! @@ -515,7 +515,7 @@ h5t_get_num_leaf_levels ( h5t_mesh_t* const m ) { H5_CORE_API_ENTER (h5_ssize_t, "m=%p", m); - H5_CORE_API_RETURN (m->num_leaf_levels); + H5_RETURN (m->num_leaf_levels); } /*! @@ -530,7 +530,7 @@ h5t_get_level ( h5t_mesh_t* const m ) { H5_CORE_API_ENTER (h5_lvl_idx_t, "m=%p", m); - H5_CORE_API_RETURN (m->leaf_level); + H5_RETURN (m->leaf_level); } /*! @@ -557,9 +557,9 @@ h5t_get_num_leaf_elems ( UNUSED_ARGUMENT (cnode); if (m->leaf_level < 0) { - H5_CORE_API_LEAVE (h5tpriv_error_undef_level ()); + H5_LEAVE (h5tpriv_error_undef_level ()); } - H5_CORE_API_RETURN (m->num_interior_leaf_elems[m->leaf_level]); + H5_RETURN (m->num_interior_leaf_elems[m->leaf_level]); } /*! Return number of vertices on compute node \c cnode_id @@ -585,9 +585,9 @@ h5t_get_num_vertices ( UNUSED_ARGUMENT (cnode); if (m->leaf_level < 0) { - H5_CORE_API_LEAVE (h5tpriv_error_undef_level ()); + H5_LEAVE (h5tpriv_error_undef_level ()); } - H5_CORE_API_RETURN (m->num_loc_vertices[m->leaf_level]); + H5_RETURN (m->num_loc_vertices[m->leaf_level]); } /*! @@ -602,6 +602,6 @@ h5t_is_chunked ( h5t_mesh_t* const m ) { H5_CORE_API_ENTER (h5_lvl_idx_t, "m=%p", m); - H5_CORE_API_RETURN (m->is_chunked); + H5_RETURN (m->is_chunked); } diff --git a/src/h5core/h5t_octree.c b/src/h5core/h5t_octree.c index 4b44a1a..986adf5 100644 --- a/src/h5core/h5t_octree.c +++ b/src/h5core/h5t_octree.c @@ -166,7 +166,7 @@ create_mpi_type_octant ( // commit new type TRY (h5priv_mpi_type_commit (&h5_oct_dta_types.mpi_octant)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_create_mpi_type_octant (void) { return create_mpi_type_octant (); @@ -194,7 +194,7 @@ get_maxpoints ( h5t_octree_t* const octree ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p,", octree); - H5_PRIV_FUNC_RETURN (octree->maxpoints); + H5_RETURN (octree->maxpoints); } int H5t_get_maxpoints (h5t_octree_t* const octree) { return get_maxpoints (octree); @@ -208,7 +208,7 @@ set_maxpoints ( H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, maxpoints=%d", octree, maxpoints); assert (maxpoints > 0); octree->maxpoints = maxpoints; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_set_maxpoints (h5t_octree_t* const octree, int maxpoints) { @@ -242,7 +242,7 @@ set_intdata_chg ( octree->octants[oct_idx].level_idx |= ( 1 << OCT_CHG_INTERNAL); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * get new proc @@ -274,7 +274,7 @@ set_proc ( octree->octants[oct_idx].processor = proc; TRY (set_intdata_chg (octree, oct_idx)); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_set_proc (h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_int32_t proc) { @@ -294,7 +294,7 @@ set_proc_int ( octree->octants[oct_idx].processor = proc; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_set_proc_int (h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_int32_t proc) { @@ -316,7 +316,7 @@ set_userlevel ( TRY (set_intdata_chg (octree, oct_idx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_set_userlevel (h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_oct_level_t level) { return set_userlevel (octree, oct_idx, level); @@ -334,7 +334,7 @@ get_userlevel ( level = octree->octants[oct_idx].userlevels ; level = ((level | 1 << (OCT_USERLEV_LENGTH - 1)) ^ (1 << (OCT_USERLEV_LENGTH - 1))); // remove leave level bit - H5_PRIV_FUNC_RETURN (level); + H5_RETURN (level); } h5_oct_level_t H5t_get_userlevel (h5t_octree_t* octree, h5_oct_idx_t oct_idx) { return get_userlevel (octree, oct_idx); @@ -353,7 +353,7 @@ set_userlevel_int ( octree->octants[oct_idx].userlevels |= ( 1 << level); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } // is an internal function - maybe if there is a usecase one could make it API but is dangerous // to use since it could create a missmatch in level definitions an different procs @@ -376,7 +376,7 @@ remove_userlevel ( octree->octants[oct_idx].userlevels ^= ( 1 << level); TRY (set_intdata_chg (octree, oct_idx)); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -391,7 +391,7 @@ remove_userlevel_int ( octree->octants[oct_idx].userlevels ^= ( 1 << level); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * set leave level @@ -413,7 +413,7 @@ set_leave_level ( } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if 0 @@ -432,7 +432,7 @@ clear_all_levels ( } set_leave_level (octree); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -446,7 +446,7 @@ clear_level_internal ( octree->octants[i].level_idx ^= (1 << OCT_CHG_INTERNAL); } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -591,7 +591,7 @@ 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_PRIV_FUNC_LEAVE( h5_error ( + H5_LEAVE( h5_error ( H5_ERR_INVAL, "Multiple cores tried to update the same userdata with idx: %d", oct_idx_to_check)); @@ -658,7 +658,7 @@ update_userdata ( TRY (h5_free (changed_oct_idx)); //MPI_Type_free(&userdata_type); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); }; h5_err_t H5t_update_userdata (h5t_octree_t* const octree) { @@ -728,7 +728,7 @@ update_internal ( TRY (h5_free (oct_idx)); TRY (h5_free (nbr_oct_changed)); TRY (h5_free (recv_displs)); - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } TRY (changed_oct_idx = h5_calloc (nbr_glb_oct_changed, sizeof (*changed_oct_idx))); TRY (mpi_allgatherv (oct_idx, @@ -748,7 +748,7 @@ update_internal ( 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_PRIV_FUNC_LEAVE(H5_ERR_INVAL) + H5_LEAVE(H5_ERR_INVAL) }; }; }; @@ -802,7 +802,7 @@ update_internal ( TRY (h5_free (changed_oct_idx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); }; h5_err_t H5t_update_internal (h5t_octree_t* const octree) { @@ -838,7 +838,7 @@ get_userdata_r ( char* userdata_int = (char*) octree->userdata; *userdata = &userdata_int[oct_idx * octree->size_userdata]; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_get_userdata_r (h5t_octree_t* octree, h5_oct_idx_t oct_idx, void** userdata) { @@ -863,7 +863,7 @@ get_userdata_rw ( userdata_int = octree->userdata; *userdata = &userdata_int[oct_idx * octree->size_userdata]; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_get_userdata_rw (h5t_octree_t* octree, h5_oct_idx_t oct_idx, void** userdata) { @@ -905,7 +905,7 @@ grow_octree ( } octree->nbr_alloc_oct += additional_size; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -938,7 +938,7 @@ reset_userdata ( octree->octants[i].level_idx &= ~(1 << OCT_CHG_USERDATA); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif /* @@ -979,7 +979,7 @@ create_octant ( current_octant->processor = 0; } current_octant->userlevels = 0; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); }; /* @@ -991,12 +991,12 @@ create_root_octant ( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); if (octree->octants == NULL || octree->nbr_alloc_oct < 1) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } TRY (create_octant (octree,-1)); octree->octants[0].level_idx = 0; TRY (set_leave_level(octree)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); }; /* * Initialize an octree @@ -1011,8 +1011,8 @@ init_octree ( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, size_userdata=%d, " - "bounding_box=%p, " - "maxpoints=%d, comm=?", + "bounding_box=%p, " + "maxpoints=%d, comm=?", octree, size_userdata, bounding_box, @@ -1025,7 +1025,7 @@ init_octree ( if (bounding_box != NULL && (bounding_box[0] >= bounding_box[3] || bounding_box[1] >= bounding_box[4] || bounding_box[2] >= bounding_box[5])) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); }; /*** allocate octree ***/ @@ -1051,7 +1051,7 @@ init_octree ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); }; h5_err_t H5t_init_octree (h5t_octree_t** octree, h5_int32_t size_userdata, h5_float64_t* const bounding_box, h5_int32_t maxpoints, const MPI_Comm comm) { @@ -1060,23 +1060,23 @@ h5_err_t H5t_init_octree (h5t_octree_t** octree, h5_int32_t size_userdata, h5_fl static h5_err_t read_octree ( - h5t_octree_t** octree, - h5_oct_idx_t current_oct_idx, - h5_int32_t size_userdata, - h5_int32_t maxpoints, - h5t_octant_t** octants, - void** userdata, - const MPI_Comm comm - ) { + h5t_octree_t** octree, + h5_oct_idx_t current_oct_idx, + h5_int32_t size_userdata, + h5_int32_t maxpoints, + h5t_octant_t** octants, + void** userdata, + const MPI_Comm comm + ) { H5_PRIV_FUNC_ENTER (h5_err_t, - "octree=%p, current_oct_idx=%d, size_userdata=%d, " - "maxpoints=%d, octants=%p, userdata=%p, comm=?", - octree, - current_oct_idx, - size_userdata, - maxpoints, - octants, - userdata); + "octree=%p, current_oct_idx=%d, size_userdata=%d, " + "maxpoints=%d, octants=%p, userdata=%p, comm=?", + octree, + current_oct_idx, + size_userdata, + maxpoints, + octants, + userdata); TRY (h5priv_mpi_barrier (comm)); // delete for speed up? @@ -1097,7 +1097,7 @@ read_octree ( (*octree)->current_oct_idx = current_oct_idx; (*octants) = (*octree)->octants; (*userdata) = (*octree)->userdata; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_read_octree (h5t_octree_t** octree, h5_oct_idx_t current_oct_idx, h5_int32_t size_userdata, h5_int32_t maxpoints, h5t_octant_t** octants, void** userdata, const MPI_Comm comm) { return read_octree (octree, current_oct_idx, size_userdata, maxpoints, octants, userdata, comm); @@ -1107,7 +1107,7 @@ h5_err_t H5t_read_octree (h5t_octree_t** octree, h5_oct_idx_t current_oct_idx, h */ static h5_err_t free_oct ( - h5t_octree_t* octree) { + h5t_octree_t* octree) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); if (octree != NULL) { if (octree->userdata != NULL) { @@ -1118,19 +1118,19 @@ free_oct ( TRY (h5_free (octree)); octree = NULL; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_free_octree (h5t_octree_t* octree) { return free_oct (octree); } static h5_err_t write_octree ( - h5t_mesh_t* const m - ) { + h5t_mesh_t* const m + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); - H5_PRIV_FUNC_RETURN (h5_error_not_implemented ()); + H5_RETURN (h5_error_not_implemented ()); } h5_err_t H5t_write_octree ( h5t_mesh_t* const m) { return write_octree (m); @@ -1155,7 +1155,7 @@ print_octree_dbg ( octree->current_oct_idx, rank, octree->nbr_alloc_oct); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * Print octree in human readable form @@ -1175,7 +1175,7 @@ print_octree ( octree->current_oct_idx, rank, octree->nbr_alloc_oct); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * Traverse through octants and print them in human readable form @@ -1215,7 +1215,7 @@ print_octants ( } #endif - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -1255,7 +1255,7 @@ print_octants_arr ( } #endif - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif ///* @@ -1318,10 +1318,10 @@ int print_octant_for_gnuplot ( } h5_err_t -plot_octants ( +h5priv_plot_octants ( h5t_octree_t* octree ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); + H5_PRIV_API_ENTER (h5_err_t, "octree=%p", octree); // h5_debug ("# start plot octants",""); h5_float64_t bounding_box[6]; int i; @@ -1336,7 +1336,7 @@ plot_octants ( "set label \" %d \" at first %4.4f, first %4.4f font \"Helvetica,7\"\n",octree->octants[i].idx, bounding_box[0] + 0.02 + 0.6 * bounding_box[1], bounding_box[2] + 0.02 + 0.4 * bounding_box[1]); } // h5_debug ("# end plot octants",""); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -1347,11 +1347,11 @@ get_siblings( ); h5_err_t -plot_octant_anc ( +h5priv_plot_octant_anc ( h5t_octree_t* octree, h5_oct_idx_t oct_idx ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); + H5_PRIV_API_ENTER (h5_err_t, "octree=%p", octree); // h5_debug ("# start plot octants",""); h5_float64_t bounding_box[6]; do { @@ -1365,13 +1365,14 @@ plot_octant_anc ( } } while ((oct_idx = get_parent(octree, oct_idx)) != -1); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } + h5_err_t -plot_leaf_octants ( +h5priv_plot_leaf_octants ( h5t_octree_t* octree ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); + H5_PRIV_API_ENTER (h5_err_t, "octree=%p", octree); h5_float64_t bounding_box[6]; h5t_oct_iterator_t* iter; @@ -1400,7 +1401,7 @@ plot_leaf_octants ( counter++, bounding_box[0] + 0.02 + 0.6 * bounding_box[1], bounding_box[2] + 0.02 + 0.4 * bounding_box[1]); } TRY (H5t_end_iterate_oct(iter)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } void print_array ( @@ -1429,7 +1430,7 @@ begin_refine_octants( TRY (h5priv_mpi_barrier (octree->comm)); update_internal (octree); octree->ref_oct_idx = octree->current_oct_idx; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * Refine an octant @@ -1445,12 +1446,12 @@ refine_octant( if (octree->octants[oct_idx].processor != rank ) { h5_debug ("Trying to refine an octant that doesn't belong to proc"); - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } if (octree->octants[oct_idx].child_idx != -1 || octree->ref_oct_idx == -1) { h5_debug ("Either octant is already refined or begin_refine_octants() was not invoked"); - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } if( octree->current_oct_idx + 1 + 8 >= octree->nbr_alloc_oct) { /*** need to allocate more memory for octants ***/ @@ -1477,7 +1478,7 @@ refine_octant( set_leave_level (octree); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * end refine octants @@ -1490,7 +1491,7 @@ end_refine_octants( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); if (octree->ref_oct_idx == -1) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } // exchange how many new octants per proc where created @@ -1580,7 +1581,7 @@ end_refine_octants( for (int i = octree->current_oct_idx; i > octree->ref_oct_idx ; i--) { h5_oct_idx_t parent_idx = get_parent (octree, i); if (parent_idx < 0 || parent_idx > octree->current_oct_idx) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } octree->octants[parent_idx].child_idx = i; @@ -1597,7 +1598,7 @@ end_refine_octants( update_userdata (octree); clear_level_internal (octree); update_internal (octree); // maybe update leave level would be enough - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -1653,12 +1654,12 @@ int sort_points_z(const void *p_a, const void *p_b) */ static h5_err_t sort_array ( - h5_oct_point_t* key, - h5_oct_point_t* points, - h5_int32_t nbr_points, - h5_oct_point_t** split, - h5_int32_t* nbr_in_split - ) { + h5_oct_point_t* key, + h5_oct_point_t* points, + h5_int32_t nbr_points, + h5_oct_point_t** split, + h5_int32_t* nbr_in_split + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "key=%p, points=%p, nbr_points=%d, split=%p, nbr_in_split=%p", key, points, nbr_points, split, nbr_in_split); @@ -1735,7 +1736,7 @@ sort_array ( } nbr_in_split[6] -= nbr_in_split[7]; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * get_midpoint @@ -1749,7 +1750,7 @@ get_midpoint ( midpoint->x = (bounding_box[3] + bounding_box[0]) / 2.0; midpoint->y = (bounding_box[4] + bounding_box[1]) / 2.0; midpoint->z = (bounding_box[5] + bounding_box[2]) / 2.0; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * function to calculate bounding box of child with orientation orient @@ -1757,10 +1758,10 @@ get_midpoint ( static h5_err_t get_new_bounding_box ( - h5_float64_t* bb, - h5_float64_t* new_bb, - h5_oct_orient_t orient - ) { + h5_float64_t* bb, + h5_float64_t* new_bb, + h5_oct_orient_t orient + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "midpoint=%p, bounding_box=%p, orient=%d", bb, new_bb, orient); h5_float64_t xmin, xmid, xmax, ymin, ymid, ymax, zmin, zmid, zmax; @@ -1801,7 +1802,7 @@ get_new_bounding_box ( new_bb[2] = zmin; new_bb[5] = zmid; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } void print_array_p ( h5_oct_point_t* neigh, @@ -1820,13 +1821,13 @@ void print_array_p ( */ static h5_err_t recursive_ref_points ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_float64_t* bounding_box, - h5_oct_point_t* points, - h5_int32_t nbr_points, - h5_int32_t max_points - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_float64_t* bounding_box, + h5_oct_point_t* points, + h5_int32_t nbr_points, + h5_int32_t max_points + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d points=%p, bounding_box=%p, nbr_points=%d, max_points=%d", octree, @@ -1869,7 +1870,7 @@ recursive_ref_points ( } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -1877,16 +1878,19 @@ recursive_ref_points ( */ static h5_err_t refine_w_points ( - h5t_octree_t* octree, - h5_oct_point_t* points, - h5_int32_t nbr_points, - h5_int32_t max_points - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, points=%p, nbr_points=%d, max_points=%d", octree, points, nbr_points, max_points); + h5t_octree_t* octree, + h5_oct_point_t* points, + h5_int32_t nbr_points, + h5_int32_t max_points + ) { + H5_PRIV_FUNC_ENTER ( + h5_err_t, + "octree=%p, points=%p, nbr_points=%d, max_points=%d", + octree, points, nbr_points, max_points); if (nbr_points < 1) { TRY (begin_refine_octants (octree)); TRY (end_refine_octants (octree, points, nbr_points)); - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } TRY (begin_refine_octants (octree)); @@ -1927,16 +1931,16 @@ refine_w_points ( } TRY (end_refine_octants (octree, points, nbr_points)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_refine_w_points (h5t_octree_t* octree, h5_oct_point_t* points, h5_int32_t nbr_points, h5_int32_t max_points) { return refine_w_points (octree, points, nbr_points, max_points); } static int bounding_box_contains_point ( - h5_float64_t* bounding_box, - h5_oct_point_t* point - ) { + h5_float64_t* bounding_box, + h5_oct_point_t* point + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "bounding_box=%p, point=%p", bounding_box, point); if ( bounding_box[0] <= point->x && bounding_box[3] > point->x && @@ -1945,18 +1949,18 @@ bounding_box_contains_point ( bounding_box[2] <= point->z && bounding_box[5] > point->z ) { - H5_PRIV_FUNC_LEAVE (1); + H5_LEAVE (1); } else { - H5_PRIV_FUNC_LEAVE (0); + H5_LEAVE (0); } - H5_PRIV_FUNC_RETURN (H5_ERR); + H5_RETURN (H5_ERR); } static h5_err_t get_bounding_box_of_octant ( - h5t_octree_t* const octree, - h5_oct_idx_t oct_idx, - h5_float64_t* bounding_box - ) { + h5t_octree_t* const octree, + h5_oct_idx_t oct_idx, + h5_float64_t* bounding_box + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, bounding_box=%p", octree, oct_idx, bounding_box); // get level and allocate memory to store all ancestors @@ -1983,7 +1987,7 @@ get_bounding_box_of_octant ( TRY (get_new_bounding_box(bounding_box, bounding_box, direction)); } TRY (h5_free (ancestors)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_get_bounding_box_of_octant (h5t_octree_t* const octree, h5_oct_idx_t oct_idx, h5_float64_t* bounding_box) { @@ -1992,16 +1996,16 @@ H5t_get_bounding_box_of_octant (h5t_octree_t* const octree, h5_oct_idx_t oct_idx static h5_oct_idx_t find_leafoctant_of_point ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_float64_t* bounding_box, - h5_oct_point_t* point - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_float64_t* bounding_box, + h5_oct_point_t* point + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, point=%p", octree, oct_idx, point); // if point is not contained in octree return error if (!bounding_box_contains_point (bounding_box, point)) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } h5_oct_idx_t ret_oct_idx = oct_idx; // if octant has children find the child that contains it and search -> recursively @@ -2017,7 +2021,7 @@ find_leafoctant_of_point ( } } - H5_PRIV_FUNC_RETURN (ret_oct_idx); + H5_RETURN (ret_oct_idx); } h5_oct_idx_t H5t_find_leafoctant_of_point (h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_float64_t* bounding_box, h5_oct_point_t* point) { @@ -2030,9 +2034,10 @@ H5t_find_leafoctant_of_point (h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_flo */ static h5_err_t add_points_to_leaf ( - h5t_octree_t* octree, - h5_oct_point_t* points, - h5_int32_t nbr_points) { + h5t_octree_t* octree, + h5_oct_point_t* points, + h5_int32_t nbr_points + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, points=%p, nbr_points=%d", octree, points, nbr_points); h5_float64_t bounding_box[6]; for (int i = 0; i < nbr_points; i++) { @@ -2040,7 +2045,7 @@ add_points_to_leaf ( TRY (points[i].oct = find_leafoctant_of_point (octree, points[i].oct, bounding_box, &points[i])); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_add_points_to_leaf (h5t_octree_t* octree, h5_oct_point_t* points, h5_int32_t nbr_points) { @@ -2060,13 +2065,13 @@ get_siblings( if (oct_idx == 0) { /*** root node has no siblings***/ - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } else { h5_oct_idx_t parent_idx = octree->octants[oct_idx].parent_idx; *siblings_idx = octree->octants[parent_idx].child_idx; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -2079,7 +2084,7 @@ get_sibling( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d", octree, oct_idx); assert (oct_idx >0); - H5_PRIV_FUNC_RETURN ( + H5_RETURN ( octree->octants[octree->octants[oct_idx].parent_idx].child_idx); } @@ -2098,7 +2103,7 @@ mem_usage ( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, mem_use=%p", octree, mem_use); *mem_use = sizeof (*octree) + (sizeof (*(octree->octants)) + octree->size_userdata) * octree->nbr_alloc_oct; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -2114,7 +2119,7 @@ free_neigh ( H5_PRIV_FUNC_ENTER (h5_err_t, "neighbors=%p, ancestor_of_neigh=%p", neighbors, ancestor_of_neigh); TRY (h5_free (neighbors)); TRY (h5_free (ancestor_of_neigh)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -2130,11 +2135,11 @@ return *(h5_oct_idx_t*)p_a - *(h5_oct_idx_t*)p_b; */ static h5_err_t add_neigh ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_oct_idx_t* neigh, - h5_oct_idx_t* num_neigh - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t* neigh, + h5_oct_idx_t* num_neigh + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, ancestor_of_neigh=%p, nbr_anc_of_neigh=%d", octree, oct_idx, @@ -2142,25 +2147,25 @@ add_neigh ( int i = 0; for (; i < *num_neigh; i++) { if (oct_idx == neigh[i]) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } } neigh[*num_neigh] = oct_idx; (*num_neigh)++; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * add ancestor to array if it doesn't exists yet (sort ancestors) */ static h5_err_t add_ancestor ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_oct_idx_t* ancestor_of_neigh, - h5_oct_idx_t* nbr_anc_of_neigh - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t* ancestor_of_neigh, + h5_oct_idx_t* nbr_anc_of_neigh + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, ancestor_of_neigh=%p, nbr_anc_of_neigh=%d", octree, oct_idx, @@ -2172,18 +2177,18 @@ add_ancestor ( (*nbr_anc_of_neigh)++; qsort(ancestor_of_neigh, (size_t) *nbr_anc_of_neigh, sizeof (*nbr_anc_of_neigh), compare_oct_idx); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * get ancestors of octant */ static h5_err_t get_ancestors ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_oct_idx_t* ancestor_of_neigh, - h5_oct_idx_t* nbr_anc_of_neigh - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t* ancestor_of_neigh, + h5_oct_idx_t* nbr_anc_of_neigh + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, ancestor_of_neigh=%p, nbr_anc_of_neigh=%d", octree, oct_idx, @@ -2192,7 +2197,7 @@ get_ancestors ( while ((parent_idx = get_parent (octree, parent_idx)) != -1 ) { TRY (add_ancestor (octree, parent_idx, ancestor_of_neigh, nbr_anc_of_neigh)); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * get children with given orientation on certain level @@ -2248,7 +2253,7 @@ get_kids_with_orient ( // add octant as ancestor and go to children h5_oct_idx_t children_oct_idx = get_children (octree, oct_idx); if (children_oct_idx == -1) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } for (int i = 0; i < 8; i++) { if ( (ifsibling && (i & direction) == (orient & direction)) || @@ -2271,7 +2276,7 @@ get_kids_with_orient ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -2310,7 +2315,7 @@ get_nca ( parent_idx = get_parent (octree, parent_idx); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * get the child with given orientation, return -1 if no children @@ -2361,20 +2366,20 @@ get_equal_sized_neigh ( child_orient = sibling_orient[orient_idx--] ^ direction; if ( (child = get_child_with_orient (octree, child, child_orient)) == -1 ) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } } *neigh = child; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t check_neigh_cand ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_oct_idx_t* neig, - h5_oct_idx_t* num_neigh - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t* neig, + h5_oct_idx_t* num_neigh + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, neig=%p, num_neigh=%p, ", octree, oct_idx, neig, num_neigh); int if_check_fails_is_int_error = 0; @@ -2392,7 +2397,7 @@ check_neigh_cand ( bb[2] > n_bb[5] || bb[5] < n_bb[2] ) { // should be deleted if (if_check_fails_is_int_error) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } else { *num_neigh = 0; } @@ -2401,20 +2406,20 @@ check_neigh_cand ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t add_common_neigh ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_oct_idx_t* neigh, - h5_oct_idx_t* num_neigh, - h5_oct_idx_t* x_neigh, - h5_oct_idx_t num_x_neigh, - h5_oct_idx_t* y_neigh, - h5_oct_idx_t num_y_neigh + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t* neigh, + h5_oct_idx_t* num_neigh, + h5_oct_idx_t* x_neigh, + h5_oct_idx_t num_x_neigh, + h5_oct_idx_t* y_neigh, + h5_oct_idx_t num_y_neigh ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d, neig=%p, num_neigh=%p, ", octree, oct_idx, neigh, num_neigh); @@ -2434,7 +2439,7 @@ add_common_neigh ( } } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } // // TODO put in separate function // h5_oct_idx_t num_cand = 0; @@ -2444,7 +2449,7 @@ add_common_neigh ( h5_err_t -get_tmp_dir_neigh ( +static get_tmp_dir_neigh ( h5t_octree_t* octree, h5_oct_idx_t size, h5_oct_idx_t* oct_idxs, @@ -2456,7 +2461,8 @@ get_tmp_dir_neigh ( h5_oct_level_t userlevel ); -h5_err_t +#if 0 +static h5_err_t get_edge_dir_neigh ( h5t_octree_t* octree, h5_oct_idx_t oct_idx, @@ -2468,6 +2474,7 @@ get_edge_dir_neigh ( h5_oct_idx_t* num_anc, h5_oct_level_t userlevel ); +#endif /* * get face neighbors of octant @@ -2493,7 +2500,7 @@ get_neighbors ( assert (kind_of_neigh < 4); // check if oct_idx has userlevel if (oct_has_level (octree, oct_idx, userlevel) == 0 ) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } h5_oct_orient_t orient = get_orient (octree, oct_idx); @@ -2835,30 +2842,46 @@ get_neighbors ( TRY (h5_free (y_anc)); TRY (h5_free (z_anc)); } - - - - H5_PRIV_FUNC_RETURN (H5_SUCCESS); -} -h5_err_t H5t_get_neighbors ( h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_oct_idx_t** neighbors, h5_oct_idx_t* nbr_neigh, h5_oct_idx_t** ancestor_of_neigh, h5_oct_idx_t* nbr_anc_of_neigh, h5_oct_idx_t kind_of_neigh, h5_oct_level_t userlevel) { - return get_neighbors (octree, oct_idx, neighbors, nbr_neigh, ancestor_of_neigh, nbr_anc_of_neigh, kind_of_neigh, userlevel); + H5_RETURN (H5_SUCCESS); } +h5_err_t +H5t_get_neighbors ( + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t** neighbors, + h5_oct_idx_t* nbr_neigh, + h5_oct_idx_t** ancestor_of_neigh, + h5_oct_idx_t* nbr_anc_of_neigh, + h5_oct_idx_t kind_of_neigh, + h5_oct_level_t userlevel + ) { + return get_neighbors ( + octree, + oct_idx, + neighbors, + nbr_neigh, + ancestor_of_neigh, + nbr_anc_of_neigh, + kind_of_neigh, + userlevel); +} + +#if 0 /* * function used to get edge neighbors */ - -h5_err_t +static h5_err_t get_edge_dir_neigh ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx, - h5_oct_idx_t tmp_oct_idx, - h5_oct_dir_t tmp_dir, - h5_oct_idx_t* neighbors, - h5_oct_idx_t* num_neigh, - h5_oct_idx_t* anc, - h5_oct_idx_t* num_anc, - h5_oct_level_t userlevel + h5t_octree_t* octree, + h5_oct_idx_t oct_idx, + h5_oct_idx_t tmp_oct_idx, + h5_oct_dir_t tmp_dir, + h5_oct_idx_t* neighbors, + h5_oct_idx_t* num_neigh, + h5_oct_idx_t* anc, + h5_oct_idx_t* num_anc, + h5_oct_level_t userlevel ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); @@ -2875,7 +2898,6 @@ get_edge_dir_neigh ( h5_oct_orient_t* orient_child_nca = NULL; TRY (orient_child_nca = h5_calloc (get_oct_level(octree, oct_idx) + 1, sizeof (*orient_child_nca))); - h5_oct_idx_t nearest_common_anc = -1; TRY (get_kids_with_orient (octree, @@ -2893,9 +2915,19 @@ get_edge_dir_neigh ( TRY (get_nca (octree, oct_idx, tmp_dir, orient_child_nca, &nearest_common_anc)); if (nearest_common_anc != -1) { - TRY (get_equal_sized_neigh (octree, oct_idx, tmp_dir, orient_child_nca, nearest_common_anc, &tmp_oct_idx, userlevel)); + TRY ( + get_equal_sized_neigh ( + octree, + oct_idx, + tmp_dir, + orient_child_nca, + nearest_common_anc, + &tmp_oct_idx, + userlevel)); - TRY (get_kids_with_orient (octree, + TRY ( + get_kids_with_orient ( + octree, tmp_oct_idx, neig_candidates, &num_cand, @@ -2920,22 +2952,22 @@ get_edge_dir_neigh ( TRY (h5_free (orient_child_nca)); TRY (h5_free (neig_candidates)); TRY (h5_free (anc_neig_cand)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } +#endif - -h5_err_t +static h5_err_t get_tmp_dir_neigh ( - h5t_octree_t* octree, - h5_oct_idx_t size, - h5_oct_idx_t* oct_idxs, - h5_oct_idx_t** neigh, - h5_oct_idx_t* num_neigh, - h5_oct_idx_t** anc, - h5_oct_idx_t* num_anc, - h5_oct_idx_t* num_alloc, - h5_oct_level_t userlevel - ) { + h5t_octree_t* octree, + h5_oct_idx_t size, + h5_oct_idx_t* oct_idxs, + h5_oct_idx_t** neigh, + h5_oct_idx_t* num_neigh, + h5_oct_idx_t** anc, + h5_oct_idx_t* num_anc, + h5_oct_idx_t* num_alloc, + h5_oct_level_t userlevel + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); h5_oct_idx_t* tmp_neigh = NULL; h5_oct_idx_t num_tmp_neigh = 0; @@ -2966,7 +2998,7 @@ get_tmp_dir_neigh ( } TRY (h5_free (tmp_neigh)); TRY (h5_free (tmp_anc)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -2976,8 +3008,8 @@ get_tmp_dir_neigh ( */ static h5_oct_idx_t iterate_oct ( - h5t_oct_iterator_t* iter - ) { + h5t_oct_iterator_t* iter + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "iter=%p", iter); h5_oct_userlev_t userlevels = 0; h5_int32_t found = 0; @@ -3001,18 +3033,22 @@ iterate_oct ( it->current_octant = -1; } } - H5_PRIV_FUNC_RETURN (it->current_octant); + H5_RETURN (it->current_octant); } -h5_oct_idx_t H5t_iterate_oct (h5t_oct_iterator_t* iter) { + +h5_oct_idx_t +H5t_iterate_oct ( + h5t_oct_iterator_t* iter + ) { return iterate_oct (iter); } static h5_err_t init_oct_iterator ( - h5t_octree_t* octree, - h5t_oct_iterator_t** iter, - h5_oct_level_t level - ) { + h5t_octree_t* octree, + h5t_oct_iterator_t** iter, + h5_oct_level_t level + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, iter=%p, level=%d", octree, iter, level); if (*iter != NULL) { TRY (h5_free (*iter)); @@ -3023,41 +3059,54 @@ init_oct_iterator ( it->current_octant = -2; it->octree = octree; it->level = level; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t H5t_init_oct_iterator (h5t_octree_t* octree, h5t_oct_iterator_t** iter, h5_oct_level_t level) { + +h5_err_t +H5t_init_oct_iterator ( + h5t_octree_t* octree, + h5t_oct_iterator_t** iter, + h5_oct_level_t level + ) { return init_oct_iterator (octree, iter, level); } static h5_err_t init_leafoct_iterator ( - h5t_octree_t* octree, - h5t_oct_iterator_t** iter - ) { + h5t_octree_t* octree, + h5t_oct_iterator_t** iter + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, iter=%p", octree, iter); init_oct_iterator (octree, iter, OCT_USERLEV_LENGTH - 1); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t H5t_init_leafoct_iterator (h5t_octree_t* octree, h5t_oct_iterator_t** iter) { +h5_err_t +H5t_init_leafoct_iterator ( + h5t_octree_t* octree, + h5t_oct_iterator_t** iter + ) { return init_leafoct_iterator (octree, iter); } static h5_err_t end_iterate_oct ( - h5t_oct_iterator_t* iter - ) { + h5t_oct_iterator_t* iter + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "iter=%p", iter); TRY (h5_free (iter)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t H5t_end_iterate_oct (h5t_oct_iterator_t* iter) { +h5_err_t +H5t_end_iterate_oct ( + h5t_oct_iterator_t* iter + ) { return end_iterate_oct (iter); } static h5_oct_idx_t get_num_oct_leaflevel ( - h5t_octree_t* octree - ) { + h5t_octree_t* octree + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p", octree); h5t_oct_iterator_t* iter = NULL; TRY (init_leafoct_iterator (octree, &iter)); @@ -3066,7 +3115,7 @@ get_num_oct_leaflevel ( counter++; } end_iterate_oct (iter); - H5_PRIV_FUNC_RETURN (counter); + H5_RETURN (counter); } h5_oct_idx_t H5t_get_num_oct_leaflevel (h5t_octree_t* octree) { return get_num_oct_leaflevel (octree); @@ -3146,7 +3195,7 @@ complete_level( parent = get_parent(octree, parent); } if (parent == -1){ - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL ); + H5_LEAVE (H5_ERR_INTERNAL ); } done = 0; // mark all parents of parent as not on level @@ -3160,7 +3209,7 @@ complete_level( end_iterate_oct (iterator); clear_level_internal (octree); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -3196,11 +3245,11 @@ check_level ( } } if (counter != 1){ - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } } end_iterate_oct (iterator); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -3217,12 +3266,12 @@ set_bounding_box ( (bounding_box[1] >= bounding_box[4]) || (bounding_box[2] >= bounding_box[5]) ) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } memcpy(octree->bounding_box, bounding_box, 6 * sizeof (*bounding_box)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t H5t_set_bounding_box ( h5t_octree_t* octree, h5_float64_t* bounding_box) { return set_bounding_box (octree, bounding_box); @@ -3247,9 +3296,14 @@ func_name ( ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d", octree, oct_idx); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t H5t_func_name (h5t_octree_t* octree, h5_oct_idx_t oct_idx) { + +h5_err_t +H5t_func_name ( + h5t_octree_t* octree, + h5_oct_idx_t oct_idx + ) { return func_name (octree, oct_idx); } diff --git a/src/h5core/h5t_retrieve.c b/src/h5core/h5t_retrieve.c index b05e727..219c432 100644 --- a/src/h5core/h5t_retrieve.c +++ b/src/h5core/h5t_retrieve.c @@ -83,7 +83,7 @@ iterate_boundary_facets ( h5_loc_id_t elem_id; TRY( elem_id = iterate_geom_boundary_elems (iter) ); if (elem_id == H5_NOK) { - H5_PRIV_FUNC_LEAVE (H5_NOK); // done! + H5_LEAVE (H5_NOK); // done! } it->elem_idx = h5tpriv_get_elem_idx (elem_id); it->face_idx = 0; @@ -93,7 +93,7 @@ iterate_boundary_facets ( } while (!h5tpriv_is_boundary_facet (it->mesh, it->elem_idx, it->face_idx)); int type = h5tpriv_ref_elem_get_entity_type (it, dim); TRY (ret_value = h5tpriv_build_entity_id (type, it->face_idx, it->elem_idx)); - H5_PRIV_FUNC_RETURN (ret_value); + H5_RETURN (ret_value); } /*! @@ -112,7 +112,7 @@ iterate_leaf_faces ( do { if (it->face_idx >= num_faces) { if (iter_leaf_elem_idx (it) == H5_NOK) { - H5_PRIV_FUNC_LEAVE (H5_NOK); // done! + H5_LEAVE (H5_NOK); // done! } it->face_idx = 0; } else { @@ -141,7 +141,7 @@ iterate_leaf_faces ( current level and the element index of entry->items[i] is the smallest element index with the given face on the current level. */ - H5_PRIV_FUNC_RETURN (entry->items[i]); + H5_RETURN (entry->items[i]); } /* @@ -165,7 +165,7 @@ iterate_boundary_faces ( h5_loc_id_t elem_id; TRY( elem_id = iterate_geom_boundary_elems (iter) ); if (elem_id == H5_NOK) { - H5_PRIV_FUNC_LEAVE (H5_NOK); // done! + H5_LEAVE (H5_NOK); // done! } it->face_idx = 0; } else { @@ -175,7 +175,7 @@ iterate_boundary_faces ( it->mesh, dim, it->elem_idx, it->face_idx)); // Skip already visited faces } while (0); - H5_PRIV_FUNC_RETURN (h5_error_internal ()); + H5_RETURN (h5_error_internal ()); } static h5_loc_id_t @@ -196,7 +196,7 @@ iterate_tags ( tags = iter->tagset->elems[iter->elem_idx]; } while ((tags == NULL) || (tags->idx[iter->subentity_idx])); #endif - H5_PRIV_FUNC_RETURN (h5_error_internal ()); + H5_RETURN (h5_error_internal ()); } h5_err_t @@ -220,7 +220,7 @@ h5t_init_leaf_iterator ( it->iter = iterate_leaf_elems; } TRY (h5tpriv_init_entity_iterator (m, iter, codim)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -239,14 +239,14 @@ h5t_init_boundary_face_iterator ( it->ref_elem = m->ref_elem; if (it->codim <= 0 || it->codim > it->ref_elem->dim) { - H5_CORE_API_LEAVE (h5tpriv_inval_codim (codim, 1, it->ref_elem->dim)); + H5_LEAVE (h5tpriv_inval_codim (codim, 1, it->ref_elem->dim)); } else if (it->codim == 1) { it->iter = iterate_boundary_facets; } else if (it->codim > 1) { it->iter = iterate_boundary_faces; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -263,7 +263,7 @@ h5t_init_mtag_iterator ( it->subentity_idx = 999; it->level_idx = m->leaf_level; it->iter = iterate_tags; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -272,7 +272,7 @@ h5t_release_entity_iterator ( ) { H5_CORE_API_ENTER (h5_err_t, "iter=%p", iter); TRY (ret_value = h5_free (iter)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_loc_id_t @@ -280,7 +280,7 @@ h5t_iterate_entities ( h5t_iterator_t* iter ) { H5_CORE_API_ENTER (h5_err_t, "iter=%p", iter); - H5_CORE_API_RETURN (iter->iter (iter)); + H5_RETURN (iter->iter (iter)); } h5_err_t @@ -293,7 +293,7 @@ h5t_end_iterate_entities ( it->face_idx = -1; it->elem_idx = -1; it->codim = -1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -309,7 +309,7 @@ h5t_get_vertex_coords_by_index ( P); h5_loc_vertex_t *vertex = &m->vertices[vertex_index]; memcpy ( P, &vertex->P, sizeof ( vertex->P ) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -326,7 +326,7 @@ h5t_get_vertex_coords_by_id ( h5_loc_idx_t vertex_index; TRY (h5tpriv_get_loc_vtx_idx_of_vtx (m, vertex_id, &vertex_index)); TRY (h5t_get_vertex_coords_by_index (m, vertex_index, P)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -344,7 +344,7 @@ h5t_get_vertex_by_id ( TRY (h5tpriv_get_loc_vtx_idx_of_vtx (m, vertex_id, &idx)); *glb_idx = m->vertices[idx].idx; *P = m->vertices[idx].P; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -365,5 +365,5 @@ h5t_get_neighbor_indices ( for (int i = 0; i < num_facets; i++) { neighbor_indices[i] = indices[i]; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5t_store.c b/src/h5core/h5t_store.c index ded7c1b..7f873f6 100644 --- a/src/h5core/h5t_store.c +++ b/src/h5core/h5t_store.c @@ -23,6 +23,8 @@ #include "h5core/h5t_map.h" +#include + #define MAX(a, b) (((a) > (b)) ? (a) : (b)) /* @@ -36,8 +38,8 @@ int max_num_elems_p_chunk = 120; // that probably doesn't belong here... //TODO put in right place + print variables h5_edge_list_t* h5tpriv_init_edge_list ( - h5_int32_t num_alloc - ) { + h5_int32_t num_alloc + ) { h5_edge_list_t* list = NULL; list = h5_calloc (1, sizeof (*list)); @@ -48,21 +50,21 @@ h5tpriv_init_edge_list ( } h5_err_t h5tpriv_free_edge_list ( - h5_edge_list_t* list - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p", list); + h5_edge_list_t* list + ) { + H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); TRY (h5_free (list->items)); list->items = NULL; TRY (h5_free(list)); list = NULL; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t h5tpriv_grow_edge_list ( - h5_edge_list_t* list, - h5_int32_t size - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p", list); + h5_edge_list_t* list, + h5_int32_t size + ) { + H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); assert (list->num_alloc + size >= 0); if (size < 0) { h5_debug ("Warning: you are shrinking the edge_list!"); @@ -71,7 +73,7 @@ h5tpriv_grow_edge_list ( h5_debug ("Warning: you are not growing the edge_list!"); } TRY ( list->items = h5_alloc(list->items, (list->num_alloc + size) * sizeof (*list->items))); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -92,11 +94,11 @@ int compare_edge_list_elem(const void *p_a, const void *p_b) { } h5_err_t h5tpriv_uniquify_edge_list ( - h5_edge_list_t* list - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p", list); + h5_edge_list_t* list + ) { + H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); if (list->num_items == 0) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } h5t_edge_list_elem_t* old_elem = list->items; int num_old_elems = list->num_items; @@ -106,7 +108,7 @@ h5tpriv_uniquify_edge_list ( for (int i = 1; i < num_old_elems; i++) { int comp = compare_edge_list_elem (&list->items[list->num_items-1], &old_elem[i] ); if (comp > 0) { // element in old_elem is smaller then last elem in list - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); // probably list wasn't sorted + H5_LEAVE (H5_ERR_INVAL); // probably list wasn't sorted } if (comp < 0) { memcpy (&list->items[list->num_items++], &old_elem[i], sizeof (*list->items)); @@ -114,44 +116,44 @@ h5tpriv_uniquify_edge_list ( } TRY (h5_free (old_elem)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t h5tpriv_sort_edge_list ( - h5_edge_list_t* list - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p", list); + h5_edge_list_t* list + ) { + H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); qsort(list->items,list->num_items, sizeof (*list->items), compare_edge_list_elem); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_int32_t h5tpriv_find_edge_list ( - h5_edge_list_t* list, - h5t_edge_list_elem_t* elem - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p", list); + h5_edge_list_t* list, + h5t_edge_list_elem_t* elem + ) { + H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); comparison_fn_t comp_func; comp_func.compare = compare_edge_list_elem; // need linear search because we want to know first elem that hits. h5t_edge_list_elem_t* retval = linsearch (elem, list->items ,list->num_items, sizeof (*list->items), comp_func); if (retval == NULL) { - H5_PRIV_FUNC_LEAVE (list->num_items); + H5_LEAVE (list->num_items); } - H5_PRIV_FUNC_RETURN (retval - list->items); // TODO check if that works + H5_RETURN (retval - list->items); // TODO check if that works } h5_err_t h5tpriv_add_edge_list ( - h5_edge_list_t* list, - h5_glb_idx_t vtx1, - h5_glb_idx_t vtx2, - h5_loc_idx_t new_vtx, - h5_int32_t proc - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p", list); + h5_edge_list_t* list, + h5_glb_idx_t vtx1, + h5_glb_idx_t vtx2, + h5_loc_idx_t new_vtx, + h5_int32_t proc + ) { + H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); h5t_edge_list_elem_t elem; elem.vtx1 = vtx1 < vtx2 ? vtx1 : vtx2; // vtx1 < vtx2 always! elem.vtx2 = vtx1 > vtx2 ? vtx1 : vtx2; @@ -161,26 +163,26 @@ h5tpriv_add_edge_list ( // add edge if (list->num_alloc == list->num_items) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } list->items[list->num_items].vtx1 = elem.vtx1; list->items[list->num_items].vtx2 = elem.vtx2; list->items[list->num_items].new_vtx = elem.new_vtx; list->items[list->num_items++].proc = proc; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } //END TODO put in right place + print variables h5_err_t h5tpriv_calc_chunk_statistic ( - h5t_mesh_t* const m, - FILE* file - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); + h5t_mesh_t* const m, + FILE* file + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p", m); if (file == NULL || m->chunks == NULL) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } fprintf (file, "# printing chunk statistics of file \n"); fprintf (file, @@ -241,7 +243,7 @@ h5tpriv_calc_chunk_statistic ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -251,10 +253,10 @@ h5tpriv_calc_chunk_statistic ( */ h5_err_t h5tpriv_get_vtx_ranges ( - h5t_mesh_t* const m, - h5_glb_idx_t* range - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, range=%p", m, range); + h5t_mesh_t* const m, + h5_glb_idx_t* range + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, range=%p", m, range); h5_glb_idx_t sendbuf = m->last_stored_vid - m->last_stored_vid_before_ref; TRY (h5priv_mpi_allgather ( @@ -282,7 +284,7 @@ h5tpriv_get_vtx_ranges ( } else { m->num_glb_vertices[m->leaf_level-1] = range[m->f->myproc]; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif /* @@ -309,7 +311,7 @@ assign_global_vertex_indices ( m->vertices[local_idx].idx = range[m->f->myproc] + counter; } if (counter + range[m->f->myproc] != range[m->f->myproc + 1]) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } TRY (h5_free (range)); } else @@ -323,7 +325,7 @@ assign_global_vertex_indices ( m->vertices[local_idx].idx = local_idx; } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if defined(WITH_PARALLEL_H5GRID) @@ -354,10 +356,10 @@ assign_global_vertex_indices_chk ( } } if (counter + vtx_range[m->f->myproc] != vtx_range[m->f->myproc + 1]) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -368,7 +370,6 @@ assign_glb_elem_indices_chk ( //TODO use ifdef instead of new func name h5t_mesh_t* const m, h5_glb_idx_t* range ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, range=%p", m, range); h5_loc_idx_t loc_idx = (m->leaf_level == 0) ? 0 : m->num_interior_elems[m->leaf_level-1]; @@ -378,9 +379,9 @@ assign_glb_elem_indices_chk ( //TODO use ifdef instead of new func name } if (counter + range[m->f->myproc] != range[m->f->myproc + 1]) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -466,7 +467,7 @@ h5tpriv_add_level ( assert (m->last_stored_eid == m->num_interior_elems[m->leaf_level - 1] - 1); } - H5_CORE_API_RETURN (m->leaf_level); + H5_RETURN (m->leaf_level); } /*! @@ -479,7 +480,7 @@ h5t_begin_store_vertices ( ) { H5_CORE_API_ENTER (h5_err_t, "m=%p, num=%llu", m, (long long unsigned)num); if (m->leaf_level < 0) { - H5_CORE_API_LEAVE (h5tpriv_error_undef_level()); + H5_LEAVE (h5tpriv_error_undef_level()); } h5_size_t cur_num_loc_vertices = (m->leaf_level > 0 ? m->num_loc_vertices[m->leaf_level-1] : 0); @@ -488,7 +489,7 @@ h5t_begin_store_vertices ( m->num_loc_vertices[m->leaf_level] = cur_num_loc_vertices+num; m->dsinfo_vertices.dims[0] = cur_num_loc_vertices+num; TRY (ret_value = h5tpriv_alloc_loc_vertices (m, cur_num_loc_vertices+num)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_loc_idx_t @@ -505,14 +506,14 @@ h5t_store_vertex ( // more than allocated if (m->last_stored_vid+1 >= m->num_loc_vertices[m->leaf_level]) - H5_CORE_API_LEAVE (HANDLE_H5_OVERFLOW_ERR( + H5_LEAVE (HANDLE_H5_OVERFLOW_ERR( m->num_loc_vertices[m->leaf_level])); h5_loc_idx_t local_idx = ++m->last_stored_vid; h5_loc_vertex_t *vertex = &m->vertices[local_idx]; vertex->idx = glb_id; /* ID from mesher, replaced later!*/ memcpy (&vertex->P, P, sizeof (vertex->P)); - H5_CORE_API_RETURN (local_idx); + H5_RETURN (local_idx); } h5_err_t @@ -525,7 +526,7 @@ h5t_end_store_vertices ( TRY (assign_global_vertex_indices (m)); TRY (h5tpriv_rebuild_map_vertex_g2l_partial (m)); m->last_stored_vid_before_ref = -1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -566,7 +567,7 @@ h5t_begin_store_elems ( m->last_stored_eid_before_ref = m->last_stored_eid; TRY (ret_value = h5tpriv_alloc_loc_elems (m, cur, new)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } @@ -586,7 +587,7 @@ h5tpriv_add_cell ( const h5_loc_idx_t* vertex_indices, const h5_weight_t* weights ) { - H5_PRIV_FUNC_ENTER (h5_loc_idx_t, + H5_PRIV_API_ENTER (h5_loc_idx_t, "m=%p, parent_idx=%lld, vertex_indices=%p, weights=%p", m, (long long)parent_idx, @@ -595,7 +596,7 @@ h5tpriv_add_cell ( /* more than allocated? */ if ( m->last_stored_eid+1 >= m->num_interior_elems[m->leaf_level] ) - H5_CORE_API_LEAVE ( + H5_LEAVE ( HANDLE_H5_OVERFLOW_ERR (m->num_interior_elems[m->leaf_level])); /* check parent id */ @@ -604,7 +605,7 @@ h5tpriv_add_cell ( (m->leaf_level > 0 && parent_idx >= m->num_interior_elems[m->leaf_level-1]) ) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( HANDLE_H5_PARENT_ID_ERR (parent_idx)); } @@ -639,7 +640,7 @@ h5tpriv_add_cell ( } } } - H5_CORE_API_RETURN (elem_idx); + H5_RETURN (elem_idx); } h5_loc_idx_t @@ -658,17 +659,17 @@ h5t_add_lvl0_cell ( m, m->last_stored_eid); int num_vertices = h5tpriv_ref_elem_get_num_vertices (m); TRY (h5tpriv_sort_local_vertex_indices (m, loc_vertex_indices, num_vertices)); - H5_CORE_API_RETURN (m->last_stored_eid); + H5_RETURN (m->last_stored_eid); } /* Rebuild mapping of global element indices to their local indices. */ -h5_err_t +static h5_err_t rebuild_map_elem_g2l ( h5t_mesh_t* const m ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); - if (m->num_leaf_levels <= 0) H5_PRIV_API_LEAVE (H5_SUCCESS); + if (m->num_leaf_levels <= 0) H5_LEAVE (H5_SUCCESS); h5_idxmap_t* map = &m->map_elem_g2l; h5_loc_idx_t loc_idx = m->leaf_level > 0 ? m->num_interior_elems[m->leaf_level-1] : 0; @@ -684,18 +685,18 @@ rebuild_map_elem_g2l ( map->num_items++; } h5priv_sort_idxmap (map); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* Rebuild mapping of global element indices to their local indices. */ -h5_err_t +static h5_err_t rebuild_map_elem_g2l_partial ( // we need that to update map for the refined elems before we have the // refined elements from the other proces h5t_mesh_t* const m ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); - if (m->num_leaf_levels <= 0) H5_PRIV_API_LEAVE (H5_SUCCESS); + if (m->num_leaf_levels <= 0) H5_LEAVE (H5_SUCCESS); h5_idxmap_t* map = &m->map_elem_g2l; h5_loc_idx_t loc_idx = m->last_stored_eid_before_ref +1; @@ -712,7 +713,7 @@ rebuild_map_elem_g2l_partial ( // we need that to update map for the refined ele } assert (map->size >= map->num_items); h5priv_sort_idxmap (map); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -739,19 +740,21 @@ h5t_end_store_elems ( /* mesh specific finalize */ TRY (m->methods->store->end_store_elems (m)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if defined(WITH_PARALLEL_H5GRID) + +#if 0 /* * linear search trough chunks to find chk_idx which contains element */ static h5_err_t -h5tpriv_find_chk_of_elem ( - h5t_mesh_t* m, - h5_loc_id_t id, - h5_chk_idx_t* chk_idx - ) { +find_chk_of_elem ( + h5t_mesh_t* m, + h5_loc_id_t id, + h5_chk_idx_t* chk_idx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, id=%lld, chk_idx=%p", m, (long long int)id, chk_idx); h5_glb_idx_t glb_idx = h5tpriv_get_loc_elem_glb_idx (m, h5tpriv_get_elem_idx (id)); @@ -765,25 +768,32 @@ h5tpriv_find_chk_of_elem ( glb_idx < m->chunks->chunks[i].elem + m->chunks->chunks[i].num_elems) { // elem is contained in chunk *chk_idx = i; - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } - } - H5_PRIV_FUNC_RETURN (H5_ERR_INVAL); + H5_RETURN (H5_ERR_INVAL); } +#endif + +#if 0 /* - * compare chk_idx + * compare chk_idx used passed to qsort */ -int compare_vtx_chk_list(const void *p_a, const void *p_b) { +static int +compare_vtx_chk_list ( + const void *p_a, + const void *p_b + ) { return ((h5t_vtx_chk_list_t*) p_a)->chk - ((h5t_vtx_chk_list_t*) p_b)->chk; } +#endif #ifdef CHUNKING_OF_VTX static h5_err_t h5tpriv_calc_vtx_permutation ( - h5t_mesh_t* m, - h5t_vtx_chk_list_t* permut - ) { + h5t_mesh_t* m, + h5t_vtx_chk_list_t* permut + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, permut=%p", m, permut); h5t_vtx_chk_list_t* b_vtx = NULL; // boundary vertices TRY (b_vtx = h5_calloc (m->num_loc_vertices[m->leaf_level], sizeof (*b_vtx))); @@ -803,7 +813,7 @@ h5tpriv_calc_vtx_permutation ( h5_chk_idx_t chk_idx = -1; int done = 0; for (int j = 0; j < list->num_items; j++) { - TRY ( h5tpriv_find_chk_of_elem (m, list->items[j], &chk_idx)); + TRY (find_chk_of_elem (m, list->items[j], &chk_idx)); if (j == 0) { old_chk_idx = chk_idx; } @@ -822,7 +832,7 @@ h5tpriv_calc_vtx_permutation ( } } if (counter + b_counter != m->num_loc_vertices[m->leaf_level]) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } // sort vtx acc to chunk qsort (permut, counter, sizeof (*permut), compare_vtx_chk_list); @@ -833,7 +843,7 @@ h5tpriv_calc_vtx_permutation ( m->first_b_vtx[0] = counter; TRY (h5_free (b_vtx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -841,45 +851,19 @@ h5tpriv_calc_vtx_permutation ( */ static h5_err_t h5tpriv_calc_vtx_revpermutation ( - h5t_mesh_t* m, - h5t_vtx_chk_list_t* permut, - h5t_vtx_chk_list_t* rev_permut - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, permut=%p, rev_permut=%p", m, permut, rev_permut); + h5t_mesh_t* m, + h5t_vtx_chk_list_t* permut, + h5t_vtx_chk_list_t* rev_permut + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, permut=%p, rev_permut=%p", m, permut, rev_permut); for (int i = 0; i < m->num_loc_vertices[m->leaf_level]; i++) { h5_loc_idx_t vtx = permut[i].vtx; rev_permut[vtx].vtx = i; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif // CHUNKING_OF_VTX #endif // WITH_PARALLEL_H5GRID -// used to chunk vtx -//static h5_err_t -//h5tpriv_store_vtx_range_to_chk ( -// h5t_mesh_t* m, -// h5t_vtx_chk_list_t* permut -// ) { -// H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, permut=%p", m, permut); -// assert (m->f->nprocs == 1); -// int counter = 0; -// h5_chk_idx_t chk_idx = -1; -// h5_glb_idx_t first_vtx = -1; -// for (int i = 0; i < m->num_loc_vertices[m->leaf_level]; i++) { -// first_vtx = i; -// chk_idx = permut[i].chk; -// counter = 1; -// while (i + 1 < m->num_loc_vertices[m->leaf_level] && chk_idx == permut[i+1].chk) { -// counter++; -// i++; -// } -// if (chk_idx != -1) { -// m->chunks->chunks[chk_idx].vtx = first_vtx; -// m->chunks->chunks[chk_idx].num_vtx = counter; -// } -// } -// H5_PRIV_FUNC_RETURN (H5_SUCCESS); -//} h5_err_t h5t_end_store_ckd_elems ( @@ -1131,7 +1115,7 @@ h5t_end_store_ckd_elems ( } #endif #endif - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef WITH_PARALLEL_H5GRID @@ -1142,7 +1126,7 @@ h5tpriv_find_oct_proc_of_point ( h5_oct_point_t* point, h5_int32_t* proc ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, loc_idx=%lld, point=%p, proc=%d", m, (long long int)loc_idx, point,*proc); + H5_PRIV_API_ENTER (h5_err_t, "m=%p, loc_idx=%lld, point=%p, proc=%d", m, (long long int)loc_idx, point,*proc); h5_loc_idx_t* indices = h5tpriv_get_loc_elem_vertex_indices (m, loc_idx); h5_float64_t midpoint[3] = {0, 0, 0}; h5_float64_t P[3]; @@ -1164,10 +1148,14 @@ h5tpriv_find_oct_proc_of_point ( // get proc of octant *proc = H5t_get_proc (m->octree, point->oct); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -int compare_midpoint_oct (const void *p_a, const void *p_b) { +static int +compare_midpoint_oct ( + const void *p_a, + const void *p_b + ) { return ((h5_oct_point_t*) p_a)->oct - ((h5_oct_point_t*) p_b)->oct; } /* @@ -1176,11 +1164,11 @@ int compare_midpoint_oct (const void *p_a, const void *p_b) { */ h5_err_t h5tpriv_mark_chk_elems_to_refine ( - h5t_mesh_t* const m, - h5_glb_idxlist_t* glb_list, - h5_oct_point_t* midpoint_list - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, glb_list=%p", m, glb_list); + h5t_mesh_t* const m, + h5_glb_idxlist_t* glb_list, + h5_oct_point_t* midpoint_list + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, glb_list=%p", m, glb_list); // clear marked_entities list TRY (h5priv_free_loc_idlist (&m->marked_entities)); TRY (h5priv_alloc_loc_idlist (&m->marked_entities, MAX_NUM_ELEMS_TO_REFINE_LOCALLY)); @@ -1217,7 +1205,7 @@ h5tpriv_mark_chk_elems_to_refine ( } // sort midpoint list such that they are aligned according to octants qsort (midpoint_list, counter, sizeof (*midpoint_list), compare_midpoint_oct); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif /* @@ -1232,7 +1220,7 @@ h5t_mark_entity ( m, (long long unsigned)entity_id); TRY (ret_value = h5priv_insert_into_loc_idlist ( &m->marked_entities, entity_id, -1)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -1240,7 +1228,7 @@ h5t_pre_refine ( h5t_mesh_t* const m ) { H5_CORE_API_ENTER (h5_err_t, "m=%p", m); - H5_CORE_API_RETURN (m->methods->store->pre_refine (m)); + H5_RETURN (m->methods->store->pre_refine (m)); } #ifdef WITH_PARALLEL_H5GRID //TODO maybe use ifdef to have name without _chk @@ -1267,7 +1255,7 @@ h5t_pre_refine_chk ( all proc is equal to glb_marked_entities->num_items this would find out if there is a problem with loading neighboring chunks... */ - H5_CORE_API_RETURN (m->methods->store->pre_refine (m)); + H5_RETURN (m->methods->store->pre_refine (m)); } #endif @@ -1283,7 +1271,7 @@ h5t_refine_marked_elems ( for (i = 0; i < m->marked_entities->num_items; i++) { TRY (h5tpriv_refine_elem (m, m->marked_entities->items[i])); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef WITH_PARALLEL_H5GRID @@ -1294,12 +1282,12 @@ h5t_refine_marked_elems ( */ h5_err_t h5tpriv_get_ranges ( - h5t_mesh_t* const m, - h5_glb_idx_t* range, - h5_glb_idx_t mycount, - h5_glb_idx_t glb_start - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, + h5t_mesh_t* const m, + h5_glb_idx_t* range, + h5_glb_idx_t mycount, + h5_glb_idx_t glb_start + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, range=%p, mycount=%lld, glb_start=%lld", m, range, (long long int) mycount, (long long int) glb_start); @@ -1317,7 +1305,7 @@ h5tpriv_get_ranges ( for (int i = 1; i <= m->f->nprocs; i++) { range[i] += range[i-1]; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -1327,10 +1315,10 @@ h5tpriv_get_ranges ( */ h5_err_t h5tpriv_get_elem_ranges ( - h5t_mesh_t* const m, - h5_glb_idx_t* range - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, range=%p", m, range); + h5t_mesh_t* const m, + h5_glb_idx_t* range + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, range=%p", m, range); h5_glb_idx_t sendbuf = m->marked_entities->num_items * h5tpriv_get_num_new_elems (m); TRY (h5priv_mpi_allgather ( &sendbuf, @@ -1346,19 +1334,21 @@ h5tpriv_get_elem_ranges ( for (int i = 1; i <= m->f->nprocs; i++) { range[i] += range[i-1]; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } + +#if 0 /* * Check if edge is on proc border. If yes also check that it hasn't been refined yet and the other proc * is also refining his element. */ -int +static int check_edge ( - h5t_mesh_t* const m, - const h5_loc_idx_t face_idx, - const h5_loc_idx_t elem_idx, - h5_glb_idxlist_t* glb_elems - ) { + h5t_mesh_t* const m, + const h5_loc_idx_t face_idx, + const h5_loc_idx_t elem_idx, + h5_glb_idxlist_t* glb_elems + ) { H5_PRIV_FUNC_ENTER (h5_loc_idx_t, "m=%p, face_idx=%lld, elem_idx=%lld, glb_elems=%p", m, (long long)face_idx, (long long)elem_idx, glb_elems); @@ -1373,7 +1363,7 @@ check_edge ( TRY (h5tpriv_get_loc_entity_children (m, retval->items[i], kids)); if (kids[0] >= 0) { // element has been refined - H5_PRIV_FUNC_LEAVE (0); + H5_LEAVE (0); } h5_loc_id_t el_id1 = retval->items[i]; h5_chk_idx_t chk_idx1 = -1; @@ -1382,10 +1372,10 @@ check_edge ( face_idx, elem_idx ); h5_chk_idx_t chk_idx2 = -2; - TRY (h5tpriv_find_chk_of_elem (m, el_id1, &chk_idx1)); - TRY (h5tpriv_find_chk_of_elem (m, el_id2, &chk_idx2)); + TRY (find_chk_of_elem (m, el_id1, &chk_idx1)); + TRY (find_chk_of_elem (m, el_id2, &chk_idx2)); if (chk_idx1 == chk_idx2) { - H5_PRIV_FUNC_LEAVE (0); + H5_LEAVE (0); } // // BUG this works depending on what is my_proc interior elems or interior_chunks //// // check weather the found element is owned by the same proc @@ -1396,23 +1386,23 @@ check_edge ( // // check if it is going to be refined // if (h5priv_find_in_glb_idxlist(glb_elems, m->loc_elems[h5tpriv_get_elem_idx(retval->items[i])].glb_idx) < 0 ) { // // element is not going to be refined -// H5_PRIV_FUNC_LEAVE (0); +// H5_LEAVE (0); // } // // check if it is on this proc // if (h5priv_find_in_loc_idlist(m->marked_entities, retval->items[i]) >= 0 ) { // // element is on same proc -// H5_PRIV_FUNC_LEAVE (0); +// H5_LEAVE (0); // } } - - - H5_PRIV_FUNC_RETURN (1); + H5_RETURN (1); } -h5_loc_idx_t +#endif + +static h5_loc_idx_t get_new_vtx_of_edge( - h5t_mesh_t* const m, - h5_loc_id_t loc_id - ) { + h5t_mesh_t* const m, + h5_loc_id_t loc_id + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, loc_id=%lld", m, (long long int)loc_id); @@ -1424,12 +1414,12 @@ get_new_vtx_of_edge( TRY (h5t_get_loc_vertex_indices_of_edge (m, kids[0], edge0)); TRY (h5t_get_loc_vertex_indices_of_edge (m, kids[1], edge1)); if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) { - H5_PRIV_FUNC_LEAVE (edge0[0]); + H5_LEAVE (edge0[0]); } else { - H5_PRIV_FUNC_LEAVE (edge0[1]); + H5_LEAVE (edge0[1]); } } - H5_PRIV_FUNC_RETURN (H5_ERR_INTERNAL); //edge that should be refined in not refined + H5_RETURN (H5_ERR_INTERNAL); //edge that should be refined in not refined } /* @@ -1439,11 +1429,11 @@ get_new_vtx_of_edge( */ h5_err_t h5tpriv_find_boundary_edges ( // todo maybe put some part into another function... - h5t_mesh_t* const m, - h5_glb_idxlist_t* glb_elems, - h5_edge_list_t* list - ) { - H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, glb_elems=%p, list=%p", + h5t_mesh_t* const m, + h5_glb_idxlist_t* glb_elems, + h5_edge_list_t* list + ) { + H5_PRIV_API_ENTER (h5_err_t, "m=%p, glb_elems=%p, list=%p", m, glb_elems, list); // go through marked elements h5_loc_idx_t elem_idx = -1; @@ -1527,18 +1517,18 @@ h5tpriv_find_boundary_edges ( // todo maybe put some part into another function. TRY (h5tpriv_sort_edge_list (list)); TRY (h5tpriv_uniquify_edge_list (list)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * exchange boundary edges info */ -h5_err_t +static h5_err_t exchange_boundary_edge_list ( - h5t_mesh_t* const m, - h5_edge_list_t* b_edges, - h5_edge_list_t* glb_b_edges - ) { + h5t_mesh_t* const m, + h5_edge_list_t* b_edges, + h5_edge_list_t* glb_b_edges + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); // TODO int* recvcounts = NULL; @@ -1578,14 +1568,14 @@ exchange_boundary_edge_list ( TRY (h5_free(recvcounts)); TRY (h5_free(recvdisp)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } -h5_err_t +static h5_err_t set_exchanged_glb_idx ( - h5t_mesh_t* const m, - h5_edge_list_t* list, - h5_edge_list_t* glb_list - ) { + h5t_mesh_t* const m, + h5_edge_list_t* list, + h5_edge_list_t* glb_list + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); // TODO for (int i = 0; i < list->num_items; i++) { @@ -1595,12 +1585,12 @@ set_exchanged_glb_idx ( m->vertices[list->items[i].new_vtx].idx = glb_list->items[retval].new_vtx; } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * find local edges in glb list and find out which proc sets glb_idx */ -h5_err_t +static h5_err_t find_edges_in_boundary_edge_list ( h5_edge_list_t* list, h5_edge_list_t* glb_list @@ -1624,12 +1614,12 @@ find_edges_in_boundary_edge_list ( } list->items[i].proc = glb_list->items[idx].proc; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * set glb_idx of new vertex into edge list -> will be exchanged to other procs */ -h5_err_t +static h5_err_t set_glb_idx_edge_list ( h5t_mesh_t* m, h5_edge_list_t* list @@ -1641,7 +1631,7 @@ set_glb_idx_edge_list ( assert (list->items[i].new_vtx != -1); } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * at the moment either split weights equally to children or assign equal as parent @@ -1666,17 +1656,17 @@ update_weight_children ( } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * function to set weights after refinement automatically */ static h5_err_t -h5tpriv_set_local_weights ( - h5t_mesh_t* m, - h5_glb_idx_t* range - ) { +set_local_weights ( + h5t_mesh_t* m, + h5_glb_idx_t* range + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, range=%p",m ,range); for (h5_glb_idx_t idx = range[m->f->myproc]; idx < range[m->f->myproc + 1]; idx++) { @@ -1693,16 +1683,16 @@ h5tpriv_set_local_weights ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * function to update weights after refinement */ static h5_err_t -h5tpriv_exchange_weights ( - h5t_mesh_t* m, - h5_glb_idx_t* range - ) { +exchange_weights ( + h5t_mesh_t* m, + h5_glb_idx_t* range + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p, range=%p",m ,range); int* recvcounts = h5_calloc (m->f->nprocs, sizeof (* recvcounts)); @@ -1731,7 +1721,7 @@ h5tpriv_exchange_weights ( for (h5_glb_idx_t i = 0; i < range[m->f->nprocs] * m->num_weights; i++ ) { assert (m->weights[i] > 0); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -1836,7 +1826,7 @@ h5t_refine_marked_elems_chk ( } else if (userdata->idx[3] == -1) { userdata->idx[3] = (h5_chk_idx_t) j; } else { - H5_CORE_API_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } } @@ -1851,23 +1841,23 @@ h5t_refine_marked_elems_chk ( TRY (h5_free (oct_c_list.items)); TRY (h5_free (elem_range)); TRY (h5_free (chk_range)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * This function checks if there is the possibility to add another chunk to an octant */ int h5tpriv_octant_is_full ( - h5t_octree_t* octree, - h5_oct_idx_t oct_idx - ) { + h5t_octree_t* octree, + h5_oct_idx_t oct_idx + ) { H5_PRIV_FUNC_ENTER (h5_err_t, "octree=%p, oct_idx=%d", octree, oct_idx); h5t_oct_userdata_t* userdata = NULL; TRY (H5t_get_userdata_r (octree, oct_idx,(void **) &userdata)); if (userdata->idx[3] == -1) { - H5_PRIV_FUNC_LEAVE (0) + H5_LEAVE (0) } - H5_PRIV_FUNC_RETURN (1); + H5_RETURN (1); } /* @@ -1931,7 +1921,7 @@ int comp_vtx_coord (void* p_a, void* p_b) { } static h5_err_t -h5tpriv_add_glb_vertex_to_list ( +add_glb_vertex_to_list ( h5t_mesh_t* const m, h5_glb_idx_t vtx_idx, h5_glb_vertex_t* glb_vtx, @@ -1945,12 +1935,12 @@ h5tpriv_add_glb_vertex_to_list ( assert (loc_idx < num_glb_vtx); memcpy (&vtx_list[*num_vtx], &glb_vtx[loc_idx], sizeof (*vtx_list)); (*num_vtx)++; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t -h5tpriv_init_glb_vtx_struct_chk ( +init_glb_vtx_struct_chk ( h5t_mesh_t* const m, h5_glb_elem_t* glb_elems, int num_glb_elems, @@ -1994,11 +1984,11 @@ h5tpriv_init_glb_vtx_struct_chk ( TRY (h5priv_hdestroy (&htab)); TRY (h5_free (map->items)); TRY (h5tpriv_sort_vertex_list (vtx_list, *num_vtx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } // little bit different funtion since it's used to store and not to load... static h5_err_t -h5tpriv_init_glb_vtx_struct_chk2 ( +init_glb_vtx_struct_chk2 ( h5t_mesh_t* const m, h5_glb_elem_t* glb_elems, int num_glb_elems, @@ -2033,14 +2023,14 @@ h5tpriv_init_glb_vtx_struct_chk2 ( if (retval == &map->items[map->num_items]) { // not in list // new entry in hash table - h5tpriv_add_glb_vertex_to_list(m, vtx_idx[j], glb_vtx, num_glb_vtx, vtx_list, num_vtx); + add_glb_vertex_to_list(m, vtx_idx[j], glb_vtx, num_glb_vtx, vtx_list, num_vtx); } } } TRY (h5priv_hdestroy (&htab)); TRY (h5tpriv_sort_vertex_list (vtx_list, *num_vtx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -2067,7 +2057,7 @@ get_list_of_chunks_to_retrieve ( } } *num_list = tmp_counter; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t exchange_glb_elem_glb_vtx ( @@ -2139,7 +2129,7 @@ exchange_glb_elem_glb_vtx ( TRY (h5_free (e_range)); TRY (h5_free (v_range)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -2213,9 +2203,9 @@ store_exchanged_elems ( // TODO maybe this function could be extended and used instead of the stuff below - //TRY (h5tpriv_init_glb_vtx_struct_chk (m, new_elems, new_elems_c, new_vtx, &new_vtx_c)); + //TRY (init_glb_vtx_struct_chk (m, new_elems, new_elems_c, new_vtx, &new_vtx_c)); // extract glb vertices that should be stored - TRY (h5tpriv_init_glb_vtx_struct_chk2 (m, new_elems, new_elems_c, + TRY (init_glb_vtx_struct_chk2 (m, new_elems, new_elems_c, glb_vtx, num_glb_vtx, new_vtx, &new_vtx_c)); // int num_vertices = h5tpriv_ref_elem_get_num_vertices(m); // for (int i = 0; i < new_elems_c; i++) { @@ -2226,7 +2216,7 @@ store_exchanged_elems ( // TRY (idx = h5tpriv_find_glb_idx_in_map (&m->map_vertex_g2l, vertices[j])); // if (idx == m->map_vertex_g2l.num_items) { // locally not available // // add at end and sort later -// h5tpriv_add_glb_vertex_to_list(m, vertices[j], glb_vtx, num_glb_vtx, new_vtx, &new_vtx_c); +// add_glb_vertex_to_list(m, vertices[j], glb_vtx, num_glb_vtx, new_vtx, &new_vtx_c); // } // } // } @@ -2257,7 +2247,7 @@ store_exchanged_elems ( TRY (h5_free (new_elems)); TRY (h5_free (new_vtx)); TRY (h5_free (proc)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -2268,7 +2258,7 @@ h5t_post_refine ( H5_CORE_API_ENTER (h5_err_t, "m=%p", m); TRY (h5t_end_store_vertices (m)); TRY (h5t_end_store_elems (m)); - H5_CORE_API_RETURN (h5priv_free_loc_idlist (&m->marked_entities)); + H5_RETURN (h5priv_free_loc_idlist (&m->marked_entities)); } @@ -2368,10 +2358,10 @@ h5t_post_refine_chk ( TRY ( m->weights = h5_alloc (m->weights, elem_range[m->f->nprocs] * m->num_weights * sizeof (*m->weights))); // set local weights - TRY (h5tpriv_set_local_weights (m, elem_range)); + TRY (set_local_weights (m, elem_range)); // exchange weights - TRY (h5tpriv_exchange_weights (m, elem_range)); + TRY (exchange_weights (m, elem_range)); } TRY (h5priv_mpi_barrier (m->f->props->comm)); m->timing.measure[m->timing.next_time++] = MPI_Wtime(); @@ -2403,7 +2393,7 @@ h5t_post_refine_chk ( h5_glb_vertex_t* glb_vtx = NULL; h5_int32_t num_glb_vtx = 0; TRY (glb_vtx = h5_calloc (4 * num_glb_elems, sizeof (*glb_vtx))); // TODO should be by far enough -> could be optimzed - TRY (h5tpriv_init_glb_vtx_struct_chk (m, glb_elems, num_glb_elems, glb_vtx, &num_glb_vtx)); + TRY (init_glb_vtx_struct_chk (m, glb_elems, num_glb_elems, glb_vtx, &num_glb_vtx)); // get list of chunks to retrieve h5_chk_idx_t* chk_list_read = NULL; @@ -2487,7 +2477,7 @@ h5t_post_refine_chk ( marked_glb_elems = NULL; - H5_CORE_API_RETURN (h5priv_free_loc_idlist (&m->marked_entities)); + H5_RETURN (h5priv_free_loc_idlist (&m->marked_entities)); } @@ -2504,7 +2494,7 @@ h5t_begin_refine_elems ( memory. */ TRY (h5priv_alloc_loc_idlist (&m->marked_entities, MAX_NUM_ELEMS_TO_REFINE_LOCALLY)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -2538,7 +2528,7 @@ h5t_end_refine_elems ( m->mesh_changed = 1; } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if defined(WITH_PARALLEL_H5GRID) @@ -2549,7 +2539,7 @@ h5tpriv_init_chunks ( H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); if (m->chunks != NULL) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INVAL); + H5_LEAVE (H5_ERR_INVAL); } TRY (m->chunks = h5_calloc (1, sizeof (*m->chunks))); m->chunks->curr_idx = -1; @@ -2558,7 +2548,7 @@ h5tpriv_init_chunks ( m->chunks->num_chunks_p_level = NULL; m->chunks->chunks = NULL; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -2584,7 +2574,7 @@ h5tpriv_grow_chunks ( m->chunks->num_levels * sizeof (*m->chunks->num_chunks_p_level))); m->chunks->num_chunks_p_level[m->chunks->num_levels - 1] = size; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -2602,7 +2592,7 @@ h5tpriv_store_chunks ( assert (chk_range[m->f->myproc+1] - chk_range[m->f->myproc] == 0); assert (elem_range[m->f->myproc+1] - elem_range[m->f->myproc] == 0); assert (num_chunks == 0); - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } int counter = 0; h5_chk_weight_t weight = 0; @@ -2622,10 +2612,10 @@ h5tpriv_store_chunks ( if ((m->chunks->curr_idx + 1 != chk_range[m->f->myproc + 1]) || (tot_loc_elem != elem_range[m->f->myproc + 1] - elem_range[m->f->myproc])) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t h5tpriv_create_chunk ( @@ -2640,7 +2630,7 @@ h5tpriv_create_chunk ( m, oct_idx,(long long) first_elem, (long long) weight, num_elems); if (m->chunks->curr_idx + 1 > m->chunks->num_alloc) { - H5_PRIV_FUNC_LEAVE (H5_ERR_INTERNAL); + H5_LEAVE (H5_ERR_INTERNAL); } if (chk_range == NULL) { m->chunks->curr_idx++; @@ -2667,7 +2657,7 @@ h5tpriv_create_chunk ( // m->chunks->chunks[m->chunks->curr_idx].num_vtx = -2; // TODO remove from chunks - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -2716,7 +2706,7 @@ h5tpriv_update_chunks ( TRY (h5_free (recvdisp)); TRY (h5_free (recvcount)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -2731,7 +2721,7 @@ h5tpriv_free_chunks ( TRY (h5_free (m->chunks->num_chunks_p_level)); TRY (h5_free (m->chunks)); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -2754,7 +2744,7 @@ h5tpriv_print_chunks ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -2775,7 +2765,7 @@ h5tpriv_print_oct_userdata ( } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif #if 0 @@ -2799,6 +2789,6 @@ h5t_create_index_set ( TRY (h5t_set_mtag_by_name (f, "__IndexSet__", entity_id, 1, &idx)); } } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif diff --git a/src/h5core/h5t_tags.c b/src/h5core/h5t_tags.c index 43a0a41..5814300 100644 --- a/src/h5core/h5t_tags.c +++ b/src/h5core/h5t_tags.c @@ -35,7 +35,7 @@ read_dataset ( hid_t (*set_dspace)(h5t_mesh_t*,hid_t), void* const data ) { - H5_PRIV_API_ENTER (h5_err_t, + H5_PRIV_FUNC_ENTER (h5_err_t, "f=%p, dset_id=%lld (%s), dsinfo=%p, set_mspace=%p, " "set_dspace=%p, data=%p", f, (long long int)dset_id, hdf5_get_objname(dset_id), @@ -59,7 +59,7 @@ read_dataset ( TRY (hdf5_close_dataspace (dspace_id)); TRY (hdf5_close_dataspace (mspace_id)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static hid_t @@ -83,14 +83,14 @@ h5t_get_num_mtagsets ( h5_ssize_t num_mtagsets = 0; h5_err_t exists = 0; TRY (exists = h5priv_link_exists (m->mesh_gid, "Tags")); - if (!exists) H5_CORE_API_LEAVE (0); + if (!exists) H5_LEAVE (0); hid_t loc_id; TRY (loc_id = h5priv_open_group (0, m->mesh_gid, "Tags")); TRY (num_mtagsets = hdf5_get_num_groups (loc_id)); TRY (hdf5_close_group (loc_id)); - H5_CORE_API_RETURN (num_mtagsets); + H5_RETURN (num_mtagsets); } @@ -121,7 +121,7 @@ get_tagset_info ( TRY (hdf5_close_dataset (dset_id)); TRY (hdf5_close_group (tag_id)); TRY (hdf5_close_group (tags_id)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -142,7 +142,7 @@ h5t_get_mtagset_info ( m, (long long unsigned)idx, name, (long long unsigned)len_name, type); TRY (ret_value = get_tagset_info(m->mesh_gid, idx, name, len_name, type)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } /*! @@ -155,7 +155,7 @@ h5t_mtagset_exists ( ) { H5_CORE_API_ENTER (h5_err_t, "m=%p, name=%s", m, name); TRY (ret_value = h5priv_link_exists (m->mesh_gid, "Tags", name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } static h5_err_t @@ -185,7 +185,7 @@ new_tagset ( TRY (h5priv_search_strlist (&m->mtagsets, name)); *rtagset = tagset; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -203,13 +203,13 @@ h5t_create_mtagset ( m, name, (long long unsigned)type, set); // validate name if (name == NULL || name[0] == '\0') { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error (H5_ERR_INVAL, "Invalid name" )); } // validate type if (type != H5_INT64 && type != H5_FLOAT64) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error (H5_ERR_INVAL, "Unsupported data type." )); } @@ -217,12 +217,12 @@ h5t_create_mtagset ( h5_err_t exists; TRY (exists = h5priv_link_exists (m->mesh_gid, "Tags", name)); if (exists || h5priv_find_strlist (m->mtagsets, name) >= 0) - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5FED, "Cannot create tagset '%s': Tagset exists", name)); TRY (ret_value = new_tagset (m, m->mesh_gid, name, type, set)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } static int @@ -258,7 +258,7 @@ remove_tag ( "tagset=%p, face_id=%lld, elem_idx=%lld", tagset, (long long)face_id, (long long)elem_idx); if (tagset->elems[elem_idx] == NULL) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_warn ( "Tag %s not set for face %llx of element %lld", tagset->name, @@ -270,7 +270,7 @@ remove_tag ( // remove values int idx = find_face_id (eleminfo, face_id); if (idx < 0) { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_warn ( "Tag %s not set for face %llx of element %lld", tagset->name, @@ -290,7 +290,7 @@ remove_tag ( (eleminfo->num_tags-idx-1)*sizeof (ti[0]) ); // we don't resize the eleminfo structure!!! - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -328,7 +328,7 @@ add_tag ( dim*sizeof (*tagset->values)); ti->val_idx = tagset->num_values; tagset->num_values += dim; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -387,7 +387,7 @@ set_tag ( if (tagset->m->leaf_level > tagset->scope.max_level) { tagset->scope.max_level = tagset->m->leaf_level; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -491,7 +491,7 @@ read_tagset ( TRY (h5_free (elems)); TRY (h5_free (entities)); TRY (h5_free (vals)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -508,20 +508,20 @@ h5t_open_mtagset ( m, name, set); // validate name if (name == NULL || name[0] == '\0') { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error (H5_ERR_INVAL, "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_CORE_API_LEAVE ( + if (!exists) H5_LEAVE ( h5_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_CORE_API_LEAVE ( + if (h5priv_find_strlist (m->mtagsets, name) >= 0) H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Cannot open tagset '%s': Already open ", name)); @@ -529,7 +529,7 @@ h5t_open_mtagset ( TRY (new_tagset (m, m->mesh_gid, name, -1, set)); TRY (read_tagset (*set)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -555,11 +555,11 @@ write_tagset ( h5t_mesh_t* m = tagset->m; if (m->num_leaf_levels <= 0) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); // nothing to do + H5_LEAVE (H5_SUCCESS); // nothing to do } num_interior_elems = m->num_interior_elems[m->num_leaf_levels-1]; if (num_interior_elems == 0 || tagset->num_entities == 0) { - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); // nothing to do + H5_LEAVE (H5_SUCCESS); // nothing to do } // allocate memory per element (plus 1) TRY (elems = h5_calloc (num_interior_elems+1, sizeof(*elems))); @@ -664,7 +664,7 @@ write_tagset ( TRY (h5_free (elems)); TRY (h5_free (entities)); TRY (h5_free (values)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -691,7 +691,7 @@ release_mtagset ( TRY (h5_free (tagset->values)); TRY (h5_free (tagset)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -708,7 +708,7 @@ h5t_close_mtagset ( TRY (write_tagset (tagset)); } TRY (release_mtagset (tagset)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -745,7 +745,7 @@ remove_tagset ( TRY (hdf5_delete_link (loc_id, "values", H5P_DEFAULT)); TRY (hdf5_close_group (loc_id)); TRY (hdf5_delete_link (tagsets_id, name, H5P_DEFAULT)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -764,7 +764,7 @@ 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_CORE_API_LEAVE ( + if (h5priv_find_strlist (m->mtagsets, name) >= 0) H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Cannot remove tagset '%s': Still open ", name)); @@ -773,7 +773,7 @@ h5t_remove_mtagset ( TRY (loc_id = hdf5_open_group (m->mesh_gid, "Tags")); TRY (remove_tagset (loc_id, name)); TRY (hdf5_close_group (loc_id)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -796,7 +796,7 @@ h5t_set_tag ( h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); TRY (set_tag (tagset, face_id, elem_idx, size, val)); tagset->changed = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -845,7 +845,7 @@ h5t_get_tag ( dim, values); if (tagset->m->leaf_level < tagset->scope.min_level) { - H5_CORE_API_LEAVE (H5_NOK); // entity not tagged + H5_LEAVE (H5_NOK); // entity not tagged } h5_loc_id_t id = entity_id; h5_err_t h5err; @@ -856,7 +856,7 @@ h5t_get_tag ( (id = h5tpriv_get_loc_entity_parent (tagset->m, id)) >= 0) ; if (h5err < 0) - H5_CORE_API_LEAVE (H5_NOK); // entity not tagged + H5_LEAVE (H5_NOK); // entity not tagged h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (id); h5t_taginfo_t* ti = &tagset->elems[elem_idx]->ti[ti_idx]; @@ -867,7 +867,7 @@ h5t_get_tag ( if (values != NULL) { memcpy (values, v + val_idx, *dim*sizeof(*v) ); } - H5_CORE_API_RETURN (id); + H5_RETURN (id); } /*! @@ -887,6 +887,6 @@ h5t_remove_tag ( h5_loc_idx_t face_id = h5tpriv_get_face_id (entity_id); h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); TRY (ret_value = remove_tag (tagset, face_id, elem_idx)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } diff --git a/src/h5core/h5u_io.c b/src/h5core/h5u_io.c index 7560527..23a791e 100644 --- a/src/h5core/h5u_io.c +++ b/src/h5core/h5u_io.c @@ -44,7 +44,7 @@ h5upriv_open_file ( TRY (u->dcreate_prop = hdf5_create_property (H5P_DATASET_CREATE)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -72,7 +72,7 @@ h5upriv_close_file ( TRY (h5_free (f->u)); f->u = NULL; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -172,7 +172,7 @@ h5u_read_data ( TRY (hdf5_close_dataset (dataset_id)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -236,5 +236,5 @@ h5u_write_data ( f->empty = 0; TRY (hdf5_flush (f->step_gid, H5F_SCOPE_LOCAL)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/h5u_model.c b/src/h5core/h5u_model.c index 6d3e59a..cb043d0 100644 --- a/src/h5core/h5u_model.c +++ b/src/h5core/h5u_model.c @@ -38,7 +38,7 @@ h5u_get_num_points ( TRY (nparticles = h5u_get_totalnum_particles_by_idx (fh, 0)); } - H5_CORE_API_RETURN (nparticles); + H5_RETURN (nparticles); } h5_ssize_t @@ -50,14 +50,14 @@ h5u_get_num_points_in_view ( h5_ssize_t nparticles; if (!h5u_has_view (fh)) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_H5PART, "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 ); - H5_CORE_API_RETURN (nparticles); + H5_RETURN (nparticles); } h5_ssize_t @@ -74,7 +74,7 @@ h5u_get_totalnum_particles_by_name ( f->step_gid, dataset_name)); h5_debug ("Found %lld particles in dataset %s.", (long long)nparticles, dataset_name); - H5_CORE_API_RETURN (nparticles); + H5_RETURN (nparticles); } h5_ssize_t @@ -93,13 +93,13 @@ h5u_get_totalnum_particles_by_idx ( dataset_name, H5_DATANAME_LEN)); if (h5err == H5_NOK) - H5_CORE_API_LEAVE (H5_NOK); + H5_LEAVE (H5_NOK); h5_ssize_t nparticles; TRY (nparticles = hdf5_get_npoints_of_dataset_by_name ( f->step_gid, dataset_name)); h5_debug ("Found %lld particles in dataset %s.", (long long)nparticles, dataset_name); - H5_CORE_API_RETURN (nparticles); + H5_RETURN (nparticles); } h5_err_t @@ -118,7 +118,7 @@ h5u_set_num_points ( hsize_t dmax = H5S_UNLIMITED; if (nparticles < 0) - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_INVAL, "Invalid number of particles: %lld!\n", @@ -132,7 +132,7 @@ h5u_set_num_points ( we don't know if things have changed globally */ if ( u->nparticles == nparticles && stride == 1 ) { - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } #endif @@ -214,7 +214,7 @@ h5u_set_num_points ( TRY (hdf5_select_none (u->diskshape)); } #endif - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -223,7 +223,7 @@ h5u_has_view ( ) { h5_file_p f = (h5_file_p)fh; H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); - H5_CORE_API_RETURN (f->u->viewindexed || f->u->viewstart >= 0); + H5_RETURN (f->u->viewindexed || f->u->viewstart >= 0); } h5_err_t @@ -242,7 +242,7 @@ h5u_reset_view ( TRY (hdf5_close_dataspace (u->memshape)); u->memshape = H5S_ALL; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -267,7 +267,7 @@ h5u_set_view ( TRY (h5u_reset_view (fh)); if (start == -1 && end == -1) // we are already done - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); if (f->u->shape > 0) { TRY (total = hdf5_get_npoints_of_dataspace (f->u->shape) ); @@ -285,7 +285,7 @@ h5u_set_view ( :FIXME: why not gather total size? */ if (start < 0) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_INVAL, "Start of selection '%lld' out of range: " @@ -294,7 +294,7 @@ h5u_set_view ( ); } if (end < start) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_INVAL, "End of selection '%lld' out of range: " @@ -322,21 +322,21 @@ h5u_set_view ( } if (start < 0 || start >= total) { - H5_CORE_API_LEAVE ( + 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)); } else if (end < 0 || end >= total) { - H5_CORE_API_LEAVE ( + 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)); } else if (end+1 < start) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_INVAL, "Invalid selection: start=%lld > end=%lld!\n", @@ -371,7 +371,7 @@ h5u_set_view ( /* declare local memory datasize */ TRY (u->memshape = hdf5_create_dataspace (1, &hcount, &dmax)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -389,7 +389,7 @@ h5u_set_view_length ( TRY (h5u_reset_view (fh)); if (start == -1 && length == -1) - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); hsize_t total = 0; if (u->shape > 0) { @@ -404,11 +404,11 @@ h5u_set_view_length ( /* No datasets have been created yet and no views are set. * We have to leave the view empty because we don't know how * many particles there should be! */ - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } if (start < 0 || length < 0 || start+length > total) - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_INVAL, "Invalid view: start=%lld, length=%lld, total=%lld", @@ -440,7 +440,7 @@ h5u_set_view_length ( /* declare local memory datasize */ hsize_t dmax = H5S_UNLIMITED; TRY (u->memshape = hdf5_create_dataspace (1, &hcount, &dmax)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -466,7 +466,7 @@ h5u_set_view_indices ( if ( indices == NULL ) { h5_warn ("View indices array is null: reseting view."); - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } if (f->u->shape > 0) { TRY (total = hdf5_get_npoints_of_dataspace (f->u->shape) ); @@ -480,7 +480,7 @@ h5u_set_view_indices ( /* No datasets have been created yet and no views are set. * We have to leave the view empty because we don't know how * many particles there should be! */ - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } u->nparticles = nelems; @@ -501,7 +501,7 @@ h5u_set_view_indices ( } u->viewindexed = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_int64_t @@ -517,7 +517,7 @@ h5u_get_view ( struct h5u_fdata *u = f->u; if ( u->viewindexed ) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "The current view has an index selection, but " @@ -540,7 +540,7 @@ h5u_get_view ( if ( start ) *start = viewstart; if ( end ) *end = viewend; - H5_CORE_API_RETURN (viewend - viewstart + 1); // view range is *inclusive* + H5_RETURN (viewend - viewstart + 1); // view range is *inclusive* } h5_err_t @@ -576,7 +576,7 @@ h5u_set_canonical_view ( h5_int64_t length = u->nparticles; TRY (h5u_set_view_length (fh, start, length)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_ssize_t @@ -586,7 +586,7 @@ h5u_get_num_datasets ( h5_file_p f = (h5_file_p)fh; H5_CORE_API_ENTER (h5_ssize_t, "f=%p", f); TRY (ret_value = hdf5_get_num_datasets (f->step_gid)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } h5_err_t @@ -599,7 +599,7 @@ h5u_has_dataset ( "f=%p, name='%s'", f, name); TRY (ret_value = hdf5_link_exists (f->step_gid, name)); - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } static inline h5_err_t @@ -619,7 +619,7 @@ get_dataset_info ( TRY (nelem_ = hdf5_get_npoints_of_dataset (dataset_id)); *dataset_nelem = nelem_; } - H5_INLINE_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -652,7 +652,8 @@ h5priv_get_dataset_info_by_idx ( strncpy (dataset_name, dataset_name_, len_dataset_name); } TRY (get_dataset_info (dataset_id, dataset_type, dataset_nelem)); - H5_PRIV_API_RETURN (H5_SUCCESS); + TRY (hdf5_close_dataset (dataset_id)); + H5_RETURN (H5_SUCCESS); } /*! @@ -684,7 +685,7 @@ h5u_get_dataset_info_by_idx ( idx, dataset_name, len_dataset_name, dataset_type, dataset_nelem)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -704,7 +705,8 @@ h5priv_get_dataset_info_by_name ( hid_t dataset_id; TRY (dataset_id = hdf5_open_dataset_by_name (id, dataset_name)); TRY (get_dataset_info (dataset_id, dataset_type, dataset_nelem)); - H5_PRIV_API_RETURN (H5_SUCCESS); + TRY (hdf5_close_dataset (dataset_id)); + H5_RETURN (H5_SUCCESS); } /*! @@ -730,7 +732,7 @@ h5u_get_dataset_info_by_name ( f->step_gid, dataset_name, dataset_type, dataset_nelem)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -752,7 +754,7 @@ h5u_set_chunk ( TRY (hdf5_set_chunk_property( f->u->dcreate_prop, 1, (hsize_t*)&size)); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -776,6 +778,6 @@ h5u_get_chunk ( *size = (h5_size_t)hsize; h5_info ("Found chunk size of %lld particles", (long long)*size); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5_attribs.h b/src/h5core/private/h5_attribs.h index 840358c..37c591f 100644 --- a/src/h5core/private/h5_attribs.h +++ b/src/h5core/private/h5_attribs.h @@ -25,7 +25,7 @@ h5priv_get_normalized_attribute_type ( (long long int)attr_id, hdf5_get_objname (attr_id)); TRY (ret_value = hdf5_get_attribute_type (attr_id)); TRY (ret_value = h5priv_normalize_type (ret_value)); - H5_PRIV_FUNC_RETURN (ret_value); + H5_RETURN (ret_value); } static inline h5_err_t @@ -65,7 +65,7 @@ h5priv_read_attrib ( hid_t normalized_file_type; TRY (normalized_file_type = h5priv_normalize_type (file_type)); if (normalized_file_type != normalized_type) - H5_PRIV_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Attribute '%s' has type '%s' but " @@ -82,7 +82,7 @@ h5priv_read_attrib ( TRY (hdf5_read_attribute (attrib_id, mem_type, attrib_value)); TRY (hdf5_close_dataspace(space_id)); TRY (hdf5_close_attribute (attrib_id)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -120,7 +120,7 @@ h5priv_write_attrib ( if (overwrite) { TRY (hdf5_delete_attribute (id, attrib_name)); } else { - H5_PRIV_API_LEAVE ( + H5_LEAVE ( h5_error (H5_ERR_H5, "Cannot overwrite attribute %s/%s", hdf5_get_objname (id), attrib_name)); @@ -137,7 +137,7 @@ h5priv_write_attrib ( TRY (hdf5_close_attribute (attrib_id)); TRY (hdf5_close_dataspace (space_id)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -170,7 +170,7 @@ get_attrib_info ( TRY (*attrib_type = h5priv_map_hdf5_type_to_enum (datatype_id)); } TRY (hdf5_close_attribute (attrib_id)); - H5_INLINE_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -189,7 +189,7 @@ h5priv_get_attrib_info_by_name ( attrib_type, attrib_nelem); hid_t attrib_id; TRY (attrib_id = hdf5_open_attribute_by_name (id, attrib_name)); - H5_PRIV_API_RETURN ( + H5_RETURN ( get_attrib_info ( attrib_id, attrib_type, attrib_nelem)); } @@ -224,7 +224,7 @@ h5priv_get_attrib_info_by_idx ( (size_t)len_attrib_name, attrib_name)); } - H5_PRIV_API_RETURN ( + H5_RETURN ( get_attrib_info ( attrib_id, attrib_type, attrib_nelem)); } diff --git a/src/h5core/private/h5_hdf5.c b/src/h5core/private/h5_hdf5.c index 8cf63a5..c212144 100644 --- a/src/h5core/private/h5_hdf5.c +++ b/src/h5core/private/h5_hdf5.c @@ -10,11 +10,13 @@ #include #include +#include "private/h5_log.h" #include "private/h5_hdf5.h" #include "h5core/h5_types.h" #include "h5core/h5_syscall.h" + /* Test whether given path exists. */ @@ -38,16 +40,16 @@ h5priv_link_exists_ ( *s++ = '/'; *s = '\0'; } - if (s+strlen(path[i])+1 >= end) H5_PRIV_API_LEAVE ( + if (s+strlen(path[i])+1 >= end) H5_LEAVE ( h5_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)); - if (!exists) H5_PRIV_FUNC_LEAVE (0); + if (!exists) H5_LEAVE (0); } - H5_PRIV_FUNC_RETURN (1); + H5_RETURN (1); } h5_err_t @@ -71,7 +73,7 @@ h5priv_open_group_ ( } else if (create_intermediate) { TRY (hid2 = hdf5_create_group (hid, path[i])); } else { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "No such group '%s/%s'.", @@ -84,7 +86,7 @@ h5priv_open_group_ ( } hid = hid2; } - H5_PRIV_FUNC_RETURN (hid); + H5_RETURN (hid); } typedef struct op_data { @@ -212,12 +214,12 @@ iter_op_count_match ( H5O_type_t type; TRY (type = iter_op_get_obj_type (g_id, name, info)); if (type != op_data->type) - H5_PRIV_FUNC_LEAVE (0); + H5_LEAVE (0); /* count if prefix matches */ if (strncmp (name, op_data->prefix, strlen(op_data->prefix)) == 0) { op_data->cnt++; } - H5_PRIV_FUNC_RETURN (0); + H5_RETURN (0); } ssize_t @@ -235,13 +237,13 @@ hdf5_get_num_groups ( &start_idx, iter_op_count, &op_data); if (herr < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get number of groups in '%s'.", hdf5_get_objname (loc_id))); } - HDF5_WRAPPER_RETURN (op_data.cnt); + H5_RETURN (op_data.cnt); } ssize_t @@ -261,14 +263,14 @@ hdf5_get_num_groups_matching_prefix ( &start_idx, iter_op_count_match, &op_data); if (herr < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get number of groups with prefix" " '%s' in '%s'.", prefix, hdf5_get_objname (loc_id))); } - HDF5_WRAPPER_RETURN (op_data.cnt); + H5_RETURN (op_data.cnt); } h5_err_t @@ -294,7 +296,7 @@ hdf5_get_name_of_group_by_idx ( &start_idx, iter_op_idx, &op_data); if (herr < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get name of group with index" @@ -302,7 +304,7 @@ hdf5_get_name_of_group_by_idx ( (long unsigned int)idx, hdf5_get_objname (loc_id))); } - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } ssize_t @@ -320,13 +322,13 @@ hdf5_get_num_datasets ( &start_idx, iter_op_count, &op_data); if (herr < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get number of datasets in '%s'.", hdf5_get_objname (loc_id))); } - HDF5_WRAPPER_RETURN (op_data.cnt); + H5_RETURN (op_data.cnt); } /* @@ -355,7 +357,7 @@ hdf5_get_name_of_dataset_by_idx ( &start_idx, iter_op_idx, &op_data); if (herr < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get name of dataset with index" @@ -364,8 +366,8 @@ hdf5_get_name_of_dataset_by_idx ( hdf5_get_objname (loc_id))); } if (op_data.cnt < 0) - HDF5_WRAPPER_LEAVE (H5_NOK); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (H5_NOK); + H5_RETURN (H5_SUCCESS); } /****** I d e n t i f i e r **************************************************/ diff --git a/src/h5core/private/h5_hdf5.h b/src/h5core/private/h5_hdf5.h index 94d2a5a..16ece33 100644 --- a/src/h5core/private/h5_hdf5.h +++ b/src/h5core/private/h5_hdf5.h @@ -14,6 +14,8 @@ #include "h5core/h5_types.h" #include "h5core/h5_err.h" +#include "h5core/h5_syscall.h" + #include "private/h5_log.h" #include "private/h5_va_macros.h" @@ -89,12 +91,12 @@ hdf5_link_exists ( H5Eset_auto(H5E_DEFAULT, old_func, old_client_data); if (exists < 0 ) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot query link %s/%s.", hdf5_get_objname (loc_id), name)); - HDF5_WRAPPER_RETURN (exists); + H5_RETURN (exists); } static inline h5_err_t @@ -108,13 +110,13 @@ hdf5_delete_link ( (long long int)loc_id, hdf5_get_objname (loc_id), name, (long long int)lapl_id); if (H5Ldelete (loc_id, name, lapl_id) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot delete link %s/%s.", hdf5_get_objname (loc_id), name)); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /****** G r o u p ************************************************************/ @@ -131,13 +133,13 @@ hdf5_open_group ( group_name); hid_t group_id = H5Gopen (loc_id, group_name, H5P_DEFAULT); if (group_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot open group '%s/%s'.", hdf5_get_objname (loc_id), group_name)); - HDF5_WRAPPER_RETURN (group_id); + H5_RETURN (group_id); } static inline hid_t @@ -153,13 +155,13 @@ hdf5_create_group ( hid_t group_id = H5Gcreate ( loc_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); if (group_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot create group '%s/%s'.", hdf5_get_objname (loc_id), group_name)); - HDF5_WRAPPER_RETURN (group_id); + H5_RETURN (group_id); } h5_err_t @@ -193,15 +195,15 @@ hdf5_close_group ( hdf5_get_objname (group_id)); if (group_id == 0 || group_id == -1) - HDF5_WRAPPER_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); if (H5Gclose (group_id) < 0 ) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot terminate access to group '%s').", hdf5_get_objname (group_id))); } - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_ssize_t @@ -214,13 +216,13 @@ hdf5_get_num_objs_in_group ( hdf5_get_objname (group_id)); H5G_info_t group_info; if (H5Gget_info (group_id, &group_info) < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get number of objects in group '%s'.", hdf5_get_objname(group_id))); } - HDF5_WRAPPER_RETURN ((h5_ssize_t)group_info.nlinks); + H5_RETURN ((h5_ssize_t)group_info.nlinks); } @@ -246,13 +248,13 @@ hdf5_get_objname_by_idx ( name, size, H5P_DEFAULT); if (len < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get name of object %llu in group '%s'.", (unsigned long long)idx, hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (len); + H5_RETURN (len); } /****** D a t a s p a c e ****************************************************/ @@ -273,12 +275,12 @@ hdf5_create_dataspace ( ); hid_t dataspace_id = H5Screate_simple (rank, dims, maxdims); if (dataspace_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot create dataspace with rank %d.", rank)); - HDF5_WRAPPER_RETURN (dataspace_id); + H5_RETURN (dataspace_id); } static inline hid_t @@ -288,11 +290,11 @@ hdf5_create_dataspace_scalar ( HDF5_WRAPPER_ENTER (hid_t, "%s", "void"); hid_t dataspace_id = H5Screate (H5S_SCALAR); if (dataspace_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot create scalar dataspace.")); - HDF5_WRAPPER_RETURN (dataspace_id); + H5_RETURN (dataspace_id); } static inline h5_err_t @@ -313,12 +315,12 @@ hdf5_select_hyperslab_of_dataspace ( count, block); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot set select hyperslap region or add the " "specified region")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -340,12 +342,12 @@ hdf5_select_elements_of_dataspace ( herr = H5Sselect_none ( space_id ); } if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot set select hyperslap region or add the " "specified region")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -357,12 +359,12 @@ hdf5_select_none ( (long long int)space_id); herr_t herr = H5Sselect_none (space_id); if (herr < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Selection for writing zero-length data failed")); } - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_ssize_t @@ -372,12 +374,12 @@ hdf5_get_selected_npoints_of_dataspace ( HDF5_WRAPPER_ENTER (h5_ssize_t, "%lld", (long long int)space_id); hssize_t size = H5Sget_select_npoints (space_id); if (size < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Cannot determine number of " "selected elements in dataspace.")); - HDF5_WRAPPER_RETURN (size); + H5_RETURN (size); } static inline h5_ssize_t @@ -387,12 +389,12 @@ hdf5_get_npoints_of_dataspace ( HDF5_WRAPPER_ENTER (h5_ssize_t, "%lld", (long long int)space_id); hssize_t size = H5Sget_simple_extent_npoints (space_id); if (size < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Cannot determine number of" "elements in dataspace.")); - HDF5_WRAPPER_RETURN (size); + H5_RETURN (size); } static inline int @@ -404,11 +406,11 @@ hdf5_get_dims_of_dataspace ( HDF5_WRAPPER_ENTER (int, "%lld", (long long int)space_id); int rank = H5Sget_simple_extent_dims (space_id, dims, maxdims); if (rank < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot determine rank of dataspace.")); - HDF5_WRAPPER_RETURN (rank); + H5_RETURN (rank); } @@ -421,16 +423,16 @@ hdf5_close_dataspace ( ) { HDF5_WRAPPER_ENTER (h5_err_t, "dataspace=%lld", (long long int)dataspace_id); if (dataspace_id <= 0 || dataspace_id == H5S_ALL) - HDF5_WRAPPER_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); herr_t herr = H5Sclose (dataspace_id); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Cannot terminate access to dataspace!")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /****** D a t a s e t ********************************************************/ @@ -452,13 +454,13 @@ hdf5_open_dataset_by_name ( dataset_name, H5P_DEFAULT); if (dataset_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot open dataset '%s/%s'.", hdf5_get_objname (loc_id), dataset_name)); - HDF5_WRAPPER_RETURN (dataset_id); + H5_RETURN (dataset_id); } /*! @@ -490,13 +492,13 @@ hdf5_create_dataset ( create_proplist, H5P_DEFAULT); if (dataset_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Cannot create dataset '%s/%s'", hdf5_get_objname (loc_id), dataset_name)); - HDF5_WRAPPER_RETURN (dataset_id); + H5_RETURN (dataset_id); } /*! @@ -511,16 +513,16 @@ hdf5_close_dataset ( (long long int)dataset_id, hdf5_get_objname (dataset_id)); if (dataset_id < 0) - HDF5_WRAPPER_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); if (H5Dclose (dataset_id) < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Close of dataset '%s' failed.", hdf5_get_objname (dataset_id))); } - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -536,12 +538,12 @@ hdf5_get_dataset_space ( hdf5_get_objname(dataset_id)); hid_t dataspace_id = H5Dget_space (dataset_id); if (dataspace_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get dataspace for dataset '%s'.", hdf5_get_objname (dataset_id))); - HDF5_WRAPPER_RETURN (dataspace_id); + H5_RETURN (dataspace_id); } /*! @@ -570,13 +572,13 @@ hdf5_write_dataset ( xfer_prop, buf); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Write to dataset '%s' failed.", \ hdf5_get_objname (dataset_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -603,13 +605,13 @@ hdf5_read_dataset ( xfer_prop, buf); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Error reading dataset '%s'.", hdf5_get_objname (dataset_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline hid_t @@ -622,12 +624,12 @@ hdf5_get_dataset_type ( hdf5_get_objname(dataset_id)); hid_t datatype_id = H5Dget_type (dataset_id); if (datatype_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Cannot determine dataset type.")); - HDF5_WRAPPER_RETURN (datatype_id); + H5_RETURN (datatype_id); } static inline h5_err_t @@ -641,13 +643,13 @@ hdf5_set_dataset_extent ( hdf5_get_objname(dataset_id), *size); if (H5Dset_extent(dataset_id, size) < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Changing size of dataset '%s' dimensions failed.", hdf5_get_objname (dataset_id))); } - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_ssize_t @@ -663,7 +665,7 @@ hdf5_get_npoints_of_dataset ( TRY (dspace_id = hdf5_get_dataset_space (dataset_id)); TRY (size = hdf5_get_npoints_of_dataspace (dspace_id)); TRY (hdf5_close_dataspace (dspace_id)); - HDF5_WRAPPER_RETURN (size); + H5_RETURN (size); } static inline h5_ssize_t @@ -681,7 +683,7 @@ hdf5_get_npoints_of_dataset_by_name ( TRY (dset_id = hdf5_open_dataset_by_name (loc_id, name)); TRY (size = hdf5_get_npoints_of_dataset (dset_id)); TRY (hdf5_close_dataset (dset_id)); - HDF5_WRAPPER_RETURN (size); + H5_RETURN (size); } /****** D a t a t y p e ******************************************************/ @@ -705,27 +707,27 @@ hdf5_get_native_type ( switch (tclass){ case H5T_INTEGER: if (size==8) { - HDF5_WRAPPER_LEAVE (H5T_NATIVE_INT64); + H5_LEAVE (H5T_NATIVE_INT64); } else if (size==4) { - HDF5_WRAPPER_LEAVE (H5T_NATIVE_INT32); + H5_LEAVE (H5T_NATIVE_INT32); } else if (size==2) { - HDF5_WRAPPER_LEAVE (H5T_NATIVE_INT16); + H5_LEAVE (H5T_NATIVE_INT16); } break; case H5T_FLOAT: if (size==8) { - HDF5_WRAPPER_LEAVE (H5T_NATIVE_FLOAT); + H5_LEAVE (H5T_NATIVE_FLOAT); } else if (size==4) { - HDF5_WRAPPER_LEAVE (H5T_NATIVE_DOUBLE); + H5_LEAVE (H5T_NATIVE_DOUBLE); } break; case H5T_STRING: - HDF5_WRAPPER_LEAVE (H5T_NATIVE_CHAR); + H5_LEAVE (H5T_NATIVE_CHAR); default: ; /* NOP */ } - HDF5_WRAPPER_RETURN ( + H5_RETURN ( h5_error ( H5_ERR_INVAL, "Unknown data type %lld", @@ -771,7 +773,7 @@ hdf5_get_type_name ( default: ret_value = "unknown"; } - HDF5_WRAPPER_RETURN (ret_value); + H5_RETURN (ret_value); } static inline const char* @@ -810,7 +812,7 @@ hdf5_create_array_type ( rank); hid_t type_id = H5Tarray_create (base_type_id, rank, dims); if (type_id < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Can't create array datatype object with base " @@ -818,7 +820,7 @@ hdf5_create_array_type ( hdf5_get_type_name (base_type_id), rank)); } - HDF5_WRAPPER_RETURN (type_id); + H5_RETURN (type_id); } static inline hid_t @@ -832,13 +834,13 @@ hdf5_create_type ( get_class_type_name (class)); hid_t type_id = H5Tcreate (class, size); if (type_id < 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Can't create datatype object of class %s.", get_class_type_name (class))); } - HDF5_WRAPPER_RETURN (type_id); + H5_RETURN (type_id); } static inline hid_t @@ -848,18 +850,18 @@ hdf5_create_string_type( HDF5_WRAPPER_ENTER (hid_t, "len = %llu", len); hid_t type_id = H5Tcopy (H5T_C_S1); if (type_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Can't duplicate C string type.")); herr_t herr = H5Tset_size (type_id, len); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Can't set length of C string type.")); - HDF5_WRAPPER_RETURN (type_id); + H5_RETURN (type_id); } static inline h5_err_t @@ -874,12 +876,12 @@ hdf5_insert_type ( (long long int)type_id, name); herr_t herr = H5Tinsert (type_id, name, offset, field_id); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Can't insert field %s to compound datatype.", name)); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline H5T_class_t @@ -889,12 +891,12 @@ hdf5_get_class_type ( HDF5_WRAPPER_ENTER (h5_err_t, "dtype_id=%lld", (long long int)dtype_id); H5T_class_t class = H5Tget_class (dtype_id); if (class < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Can't determine class of type %lld.", (long long int)dtype_id)); - HDF5_WRAPPER_RETURN (class); + H5_RETURN (class); } static inline h5_ssize_t @@ -906,13 +908,13 @@ hdf5_get_sizeof_type ( (long long int)dtype_id); h5_ssize_t size = H5Tget_size (dtype_id); if (size == 0) { - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error( H5_ERR_HDF5, "Can't determine size of type %lld.", (long long int)dtype_id)); } - HDF5_WRAPPER_RETURN (size); + H5_RETURN (size); } @@ -925,11 +927,11 @@ hdf5_close_type ( (long long int)dtype_id); herr_t herr = H5Tclose (dtype_id); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot release datatype.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /****** P r o p e r t y ******************************************************/ @@ -943,11 +945,11 @@ hdf5_create_property ( (long long int)cls_id); hid_t prop_id = H5Pcreate (cls_id); if (prop_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot create property list.")); - HDF5_WRAPPER_RETURN (prop_id); + H5_RETURN (prop_id); } /*! @@ -963,12 +965,12 @@ hdf5_get_dataset_create_plist ( hdf5_get_objname (dataset_id)); hid_t plist_id = H5Dget_create_plist (dataset_id); if (plist_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get create properties for dataset '%s'.", hdf5_get_objname (dataset_id))); - HDF5_WRAPPER_RETURN (plist_id); + H5_RETURN (plist_id); } static inline h5_err_t @@ -981,12 +983,12 @@ hdf5_set_chunk_property ( "plist=%lld, rank=%d, dims[0]=%llu ...", (long long int)plist, rank, dims[0]); if (H5Pset_chunk (plist, rank, dims) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot add chunking property to list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -999,12 +1001,12 @@ hdf5_get_chunk_property ( "plist=%lld, rank=%d", (long long int)plist, rank); if (H5Pget_chunk (plist, rank, dims) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get chunking property from list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1016,12 +1018,12 @@ hdf5_set_layout_property ( "plist=%lld", (long long int)plist); if (H5Pset_layout (plist, layout) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot add layout property to list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #ifdef PARALLEL_IO @@ -1035,12 +1037,12 @@ hdf5_set_fapl_mpio_property ( "fapl_id=%lld, comm=..., info=...", (long long int)fapl_id); if (H5Pset_fapl_mpio (fapl_id, comm, info) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot store IO communicator information to the " "file access property list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if H5_VERSION_LE(1,8,12) @@ -1054,12 +1056,12 @@ hdf5_set_fapl_mpiposix_property ( "fapl_id=%lld, comm=..., use_gpfs=%d", (long long int)fapl_id, (int)use_gpfs); if ( H5Pset_fapl_mpiposix (fapl_id, comm, use_gpfs) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot store IO communicator information to" " the file access property list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -1072,12 +1074,12 @@ hdf5_set_dxpl_mpio_property ( "dxpl_id=%lld, mode=%d", (long long int)dxpl_id, (int)mode); if (H5Pset_dxpl_mpio (dxpl_id, mode) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot store IO communicator information to" " the dataset transfer property list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -1090,12 +1092,12 @@ hdf5_set_mdc_property ( "fapl_id=%lld, config=%p", (long long int)fapl_id, config); if (H5Pset_mdc_config (fapl_id, config) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot store metadata cache configuration in" " the file access property list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1107,12 +1109,12 @@ hdf5_get_mdc_property ( "fapl_id=%lld, config=%p", (long long int)fapl_id, config); if (H5Pget_mdc_config (fapl_id, config) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get metadata cache configuration in" " the file access property list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1124,12 +1126,12 @@ hdf5_set_btree_ik_property ( "fapl_id=%lld, btree_ik=%llu", (long long int)fcpl_id, btree_ik); if (H5Pset_istore_k (fcpl_id, btree_ik) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot set btree size in the " "file access property list.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1142,13 +1144,13 @@ hdf5_set_alignment_property ( "plist=%lld, threshold=%llu, alignment=%llu", (long long int)plist, threshold, alignment); if (H5Pset_alignment (plist, threshold, alignment) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot set alignment property to %llu " "and threshold %llu", alignment, threshold)); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1160,12 +1162,12 @@ hdf5_set_meta_block_size ( "fapl_id=%lld, size=%llu", (long long int)fapl_id, size); if (H5Pset_meta_block_size (fapl_id, size) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot set meta block size property to %llu", size)); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1178,11 +1180,11 @@ hdf5_set_fapl_core ( "fapl_id=%lld, size=%zu, backing_store=%d", (long long int)fapl_id, increment, backing_store); if (H5Pset_fapl_core (fapl_id, increment, backing_store)) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot set property to use the H5FD_CORE driver.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1193,11 +1195,11 @@ hdf5_close_property ( "prop=%lld", (long long int)prop); if (H5Pclose (prop) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot close property.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /****** F i l e **************************************************************/ @@ -1209,13 +1211,20 @@ hdf5_close_file ( HDF5_WRAPPER_ENTER (h5_err_t, "file_id=%lld (%s)", (long long int)file_id, hdf5_get_objname (file_id)); - if (H5Fclose (file_id) < 0) - HDF5_WRAPPER_LEAVE ( + if (H5Fclose (file_id) < 0) { + ssize_t max_objs = H5Fget_obj_count (file_id, H5F_OBJ_ALL); + hid_t* obj_id_list = h5_calloc (max_objs, sizeof (hid_t)); + H5Fget_obj_ids (file_id, H5F_OBJ_ALL, max_objs, obj_id_list); + for (ssize_t i = 0; i < max_objs; i++) { + h5_debug ("Open object: %lld", (long long)obj_id_list[i]); + } + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot close file '%s'.", hdf5_get_objname (file_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + } + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1224,11 +1233,11 @@ hdf5_close ( ) { HDF5_WRAPPER_ENTER (h5_err_t, "%s", "void"); if (H5close () < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot close HDF5 library.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -1241,12 +1250,12 @@ hdf5_flush ( (long long int)obj_id, hdf5_get_objname (obj_id)); if (H5Fflush (obj_id, scope) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot flush data \"%s\".", hdf5_get_objname (obj_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /****** E r r o r h a n d l i n g ********************************************/ @@ -1261,11 +1270,11 @@ hdf5_set_errorhandler ( "estack_id=%lld, func=%p, client_data=%p", (long long int)estack_id, func, client_data); if (H5Eset_auto (estack_id, func, client_data) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot initialize H5.")); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /****** A t t r i b u t e ****************************************************/ @@ -1280,13 +1289,13 @@ hdf5_attribute_exists ( hdf5_get_objname (loc_id), attrib_name); htri_t exists = H5Aexists (loc_id, attrib_name); if (exists < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot query attribute '%s' of '%s'.", attrib_name, hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (exists); + H5_RETURN (exists); } static inline hid_t @@ -1300,13 +1309,13 @@ hdf5_open_attribute_by_name ( hdf5_get_objname (loc_id), attrib_name); hid_t attrib_id = H5Aopen (loc_id, attrib_name, H5P_DEFAULT); if (attrib_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot open attribute '%s' of '%s'.", attrib_name, hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (attrib_id); + H5_RETURN (attrib_id); } static inline hid_t @@ -1319,13 +1328,13 @@ hdf5_open_attribute_by_idx ( (long long int)loc_id, hdf5_get_objname (loc_id), idx); hid_t attr_id = H5Aopen_idx (loc_id, idx); if (attr_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot open attribute '%u' of '%s'.", idx, hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (attr_id); + H5_RETURN (attr_id); } static inline hid_t @@ -1349,13 +1358,13 @@ hdf5_create_attribute ( acpl_id, aapl_id); if (attr_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot create attribute '%s' for '%s'.", attr_name, hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (attr_id); + H5_RETURN (attr_id); } static inline h5_err_t @@ -1369,12 +1378,12 @@ hdf5_read_attribute ( (long long int)attr_id, hdf5_get_objname (attr_id), (long long int)mem_type_id, buf); if (H5Aread (attr_id, mem_type_id, buf) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot read attribute '%s'.", hdf5_get_objname (attr_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -1391,13 +1400,13 @@ hdf5_write_attribute ( (long long int)attr_id, hdf5_get_objname (attr_id), (long long int)mem_type_id, buf); if (H5Awrite (attr_id, mem_type_id, buf) < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot write attribute '%s'.", hdf5_get_objname (attr_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_ssize_t @@ -1412,11 +1421,11 @@ hdf5_get_attribute_name ( (unsigned long long)buf_size, buf); ssize_t size = H5Aget_name ( attr_id, buf_size, buf ); if (size < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get attribute name." )); - HDF5_WRAPPER_RETURN ((h5_size_t)size); + H5_RETURN ((h5_size_t)size); } static inline hid_t @@ -1428,12 +1437,12 @@ hdf5_get_attribute_type ( (long long int)attr_id, hdf5_get_objname (attr_id)); hid_t datatype_id = H5Aget_type (attr_id); if (datatype_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get type of attribute '%s'.", hdf5_get_objname (attr_id))); - HDF5_WRAPPER_RETURN (datatype_id); + H5_RETURN (datatype_id); } static inline hid_t @@ -1445,12 +1454,12 @@ hdf5_get_attribute_dataspace ( (long long int)attr_id, hdf5_get_objname (attr_id)); hid_t space_id = H5Aget_space (attr_id); if (space_id < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get dataspace of attribute '%s'.", hdf5_get_objname (attr_id))); - HDF5_WRAPPER_RETURN (space_id); + H5_RETURN (space_id); } static inline int @@ -1462,12 +1471,12 @@ hdf5_get_num_attribute ( (long long int)loc_id, hdf5_get_objname (loc_id)); int num = H5Aget_num_attrs (loc_id); if (num < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot get number of attributes of '%s'.", hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (num); + H5_RETURN (num); } static inline herr_t @@ -1480,13 +1489,13 @@ hdf5_delete_attribute ( (long long int)loc_id, hdf5_get_objname (loc_id), attrib_name); herr_t herr = H5Adelete (loc_id, attrib_name); if (herr < 0) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot delete attribute '%s' of '%s'.", attrib_name, hdf5_get_objname (loc_id))); - HDF5_WRAPPER_RETURN (herr); + H5_RETURN (herr); } static inline h5_err_t @@ -1497,13 +1506,13 @@ hdf5_close_attribute ( "attr_id=%lld (%s)", (long long int)attr_id, hdf5_get_objname (attr_id)); if (H5Aclose (attr_id)) - HDF5_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_HDF5, "Cannot close attribute '%s'.", hdf5_get_objname (attr_id))); - HDF5_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif diff --git a/src/h5core/private/h5_hsearch.c b/src/h5core/private/h5_hsearch.c index bcb69f3..e78054e 100644 --- a/src/h5core/private/h5_hsearch.c +++ b/src/h5core/private/h5_hsearch.c @@ -90,7 +90,7 @@ h5priv_hcreate ( /* Test for correct arguments. */ if (htab == NULL) { - H5_PRIV_API_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } /* Change nel to the first prime number not smaller as nel. */ nel |= 1; /* make odd */ @@ -108,7 +108,7 @@ h5priv_hcreate ( htab->size + 1, sizeof (_ENTRY))); /* everything went alright */ - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -157,7 +157,7 @@ h5priv_hgrow ( h5_debug ("Old hash table removed"); } *htab = __htab; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -172,7 +172,7 @@ hwalk ( TRY ((*visit)(&htab->table[idx].entry)); } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } void* @@ -201,7 +201,7 @@ h5priv_hdestroy ( H5_PRIV_API_ENTER (h5_err_t, "htab=%p", htab); /* Test for correct arguments. */ if (htab == NULL) { - H5_PRIV_API_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } /* Free used memory. */ if (htab->free_entry) { @@ -211,7 +211,7 @@ h5priv_hdestroy ( /* the sign for an existing table is an value != NULL in htable */ htab->table = NULL; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -256,7 +256,7 @@ h5priv_hsearch ( if (retval) { *retval = htab->table[idx].entry; } - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } /* Second hash function, as suggested in [Knuth] */ @@ -283,7 +283,7 @@ h5priv_hsearch ( if (retval) { *retval = htab->table[idx].entry; } - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } } while (htab->table[idx].used); } @@ -296,7 +296,7 @@ h5priv_hsearch ( if (retval) { *retval = NULL; } - H5_PRIV_API_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } htab->table[idx].used = hval; @@ -307,15 +307,15 @@ h5priv_hsearch ( if (retval) { *retval = htab->table[idx].entry; } - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } else if (action == H5_REMOVE) { htab->table[idx].used = 0; /* mark as unused, but */ *retval = htab->table[idx].entry; /* return ptr to entry */ - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } if (retval) *retval = NULL; h5_debug ("Key not found in hash table."); - H5_PRIV_API_RETURN (H5_NOK); + H5_RETURN (H5_NOK); } typedef struct { @@ -355,7 +355,7 @@ free_string_keyed ( h5_hitem_string_keyed_t* entry = (h5_hitem_string_keyed_t*) __entry; TRY (h5_free (entry->key)); TRY (h5_free (entry)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -376,5 +376,5 @@ h5priv_hcreate_string_keyed ( compute_string_keyed, free_entry)); } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5_init.c b/src/h5core/private/h5_init.c index 5cfb549..b22f8f9 100644 --- a/src/h5core/private/h5_init.c +++ b/src/h5core/private/h5_init.c @@ -66,7 +66,7 @@ create_array_types ( 1, dims) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -92,7 +92,7 @@ create_vertex_type ( HOFFSET (h5_glb_vertex_t, P), h5_dta_types.h5_coord3d_t) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -154,7 +154,7 @@ create_triangle_type ( HOFFSET(h5_glb_tri_t, neighbor_indices), h5_dta_types.h5_3glb_idx_t) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -180,7 +180,7 @@ create_tag_types ( HOFFSET (h5t_glb_tag_idx_t, idx), H5_ID) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -242,7 +242,7 @@ create_tet_type ( HOFFSET (h5_glb_tet_t, neighbor_indices), h5_dta_types.h5_4glb_idx_t) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #if defined(WITH_PARALLEL_H5GRID) @@ -298,7 +298,7 @@ create_chunk_type ( // "num_vtx", // HOFFSET (h5t_chunk_t, num_vtx), // H5_INT64) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -347,7 +347,7 @@ create_octree_type ( HOFFSET (h5t_octant_t, userlevels), H5_INT32) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -366,7 +366,7 @@ create_userdata_type ( HOFFSET (h5t_oct_userdata_t, idx), h5_dta_types.h5_4chk_idx_t) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -439,7 +439,7 @@ create_mpi_type_glb_tet ( // commit new type TRY (h5priv_mpi_type_commit (&h5_dta_types.mpi_glb_tet)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -512,7 +512,7 @@ create_mpi_type_glb_tri ( // commit new type TRY (h5priv_mpi_type_commit (&h5_dta_types.mpi_glb_triangle)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t create_mpi_type_glb_vtx ( @@ -548,7 +548,7 @@ create_mpi_type_glb_vtx ( // commit new type TRY (h5priv_mpi_type_commit (&h5_dta_types.mpi_glb_vtx)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -597,7 +597,7 @@ create_mpi_type_edge_list_elem ( // commit new type TRY (h5priv_mpi_type_commit (&h5_dta_types.mpi_edge_list_elem)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t create_mpi_type_chunk ( @@ -652,7 +652,7 @@ create_mpi_type_chunk ( // commit new type TRY (h5priv_mpi_type_commit (&h5_dta_types.mpi_chunk)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif @@ -697,5 +697,5 @@ h5priv_initialize ( TRY (create_mpi_type_chunk ()); TRY (create_mpi_type_edge_list_elem()); #endif - H5_CORE_API_RETURN ((ret_value != H5_SUCCESS) ? _h5_exit (42) : H5_SUCCESS); + H5_RETURN ((ret_value != H5_SUCCESS) ? _h5_exit (42) : H5_SUCCESS); } diff --git a/src/h5core/private/h5_io.c b/src/h5core/private/h5_io.c index da425f3..2ee220a 100644 --- a/src/h5core/private/h5_io.c +++ b/src/h5core/private/h5_io.c @@ -46,7 +46,7 @@ h5priv_write_dataset_by_name ( if ((exists > 0) && (f->props->flags & H5_O_APPENDONLY)) { h5_warn ("Dataset %s/%s already exist.", hdf5_get_objname (loc_id), dsinfo->name); - H5_PRIV_API_LEAVE (h5priv_handle_file_mode_error(f->props->flags)); + H5_LEAVE (h5priv_handle_file_mode_error(f->props->flags)); } /* @@ -93,7 +93,7 @@ h5priv_write_dataset_by_name ( TRY (hdf5_close_dataset (dset_id)); f->empty = 0; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -133,7 +133,7 @@ h5priv_write_dataset_by_name_id ( if ((exists > 0) && (f->props->flags & H5_O_APPENDONLY)) { h5_warn ("Dataset %s/%s already exist.", hdf5_get_objname (loc_id), dsinfo->name); - H5_PRIV_API_LEAVE (h5priv_handle_file_mode_error(f->props->flags)); + H5_LEAVE (h5priv_handle_file_mode_error(f->props->flags)); } TRY (h5priv_start_throttle (f)); @@ -146,5 +146,5 @@ h5priv_write_dataset_by_name_id ( data)); TRY (h5priv_end_throttle (f)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5_log.h b/src/h5core/private/h5_log.h index 8254bcf..f7bf085 100644 --- a/src/h5core/private/h5_log.h +++ b/src/h5core/private/h5_log.h @@ -14,43 +14,39 @@ #include "h5core/h5_log.h" #include "private/h5_init.h" +#if defined(NDEBUG) + +#define __FUNC_ENTER(type, mask, fmt, ...) \ + type ret_value = (type)H5_ERR; + +#else // NDEBUG not defined + +#define __FUNC_ENTER(type, mask, fmt, ...) \ + type ret_value = (type)H5_ERR; \ + int __log__ = h5_log_level & mask; \ + if (__log__ ) { \ + h5_call_stack_push (__func__,e_##type); \ + h5_debug ("(" fmt ")", __VA_ARGS__); \ + } + +#endif + #define H5_CORE_API_ENTER(type, fmt, ...) \ if (!h5_initialized) { \ h5priv_initialize(); \ } \ __FUNC_ENTER(type, H5_DEBUG_CORE_API, fmt, __VA_ARGS__) -#define H5_CORE_API_LEAVE(value) __FUNC_LEAVE(value) -#define H5_CORE_API_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_CORE_API) - #define H5_PRIV_API_ENTER(type, fmt, ...) \ __FUNC_ENTER(type, H5_DEBUG_PRIV_API, fmt, __VA_ARGS__) -#define H5_PRIV_API_LEAVE(value) __FUNC_LEAVE(value) -#define H5_PRIV_API_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_PRIV_API) - #define H5_PRIV_FUNC_ENTER(type, fmt, ...) \ __FUNC_ENTER(type, H5_DEBUG_PRIV_FUNC, fmt, __VA_ARGS__ ) -#define H5_PRIV_FUNC_LEAVE(value) __FUNC_LEAVE(value) -#define H5_PRIV_FUNC_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_PRIV_FUNC) +#define H5_INLINE_FUNC_ENTER(type) \ + type ret_value = (type)H5_ERR; int __log__ = 0; -#define HDF5_WRAPPER_ENTER(type, fmt, ...) \ +#define HDF5_WRAPPER_ENTER(type, fmt, ...) \ __FUNC_ENTER(type, H5_DEBUG_HDF5, fmt, __VA_ARGS__ ) -#define HDF5_WRAPPER_LEAVE(value) __FUNC_LEAVE(value) -#define HDF5_WRAPPER_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_HDF5) - - -#define MPI_WRAPPER_ENTER(type, fmt, ...) \ - __FUNC_ENTER(type, H5_DEBUG_MPI, fmt, __VA_ARGS__ ) -#define MPI_WRAPPER_LEAVE(value) __FUNC_LEAVE(value) -#define MPI_WRAPPER_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_MPI) - -#define H5_INLINE_FUNC_ENTER(type) type ret_value = (type)H5_ERR; -#define H5_INLINE_FUNC_LEAVE(expr) __FUNC_LEAVE(expr) -#define H5_INLINE_FUNC_RETURN(expr) __FUNC_RETURN(expr, 0) - - - #endif diff --git a/src/h5core/private/h5_lustre.c b/src/h5core/private/h5_lustre.c index 5c2bc98..0f4b058 100644 --- a/src/h5core/private/h5_lustre.c +++ b/src/h5core/private/h5_lustre.c @@ -162,7 +162,7 @@ h5_optimize_for_lustre ( config.flash_incr_mode = H5C_flash_incr__off; TRY( H5Pset_mdc_config( f->access_prop, &config ) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #endif // H5_USE_LUSTRE diff --git a/src/h5core/private/h5_maps.c b/src/h5core/private/h5_maps.c index 4fff218..2702a97 100644 --- a/src/h5core/private/h5_maps.c +++ b/src/h5core/private/h5_maps.c @@ -10,6 +10,8 @@ #include "private/h5_err.h" #include "private/h5_maps.h" +#include + /* Allocate new/empty string-list */ @@ -24,7 +26,7 @@ h5priv_alloc_strlist ( TRY (*list = h5_calloc ( 1, sizeof (**list)+size*sizeof ((*list)->items[0]))); (*list)->size = size; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -32,14 +34,14 @@ h5priv_free_strlist ( h5_strlist_t** list ) { H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); - if (list == NULL || *list == NULL) H5_PRIV_API_LEAVE (H5_SUCCESS); + if (list == NULL || *list == NULL) H5_LEAVE (H5_SUCCESS); h5_strlist_t* l = *list; for (size_t i = 0; i < l->size; i++) { TRY (h5_free(l->items[i])); } TRY (h5_free (l)); l = NULL; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -47,11 +49,11 @@ grow_strlist ( h5_strlist_t** list, size_t new_size ) { - H5_PRIV_API_ENTER (h5_err_t, "list=%p, new_size=%zu", list, new_size); + H5_PRIV_FUNC_ENTER (h5_err_t, "list=%p, new_size=%zu", list, new_size); size_t num_bytes = sizeof (**list) + (new_size-1)*sizeof((*list)->items[0]); TRY (*list = h5_alloc (*list, num_bytes)); (*list)->size = new_size; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -88,7 +90,7 @@ h5priv_insert_strlist ( } TRY (l->items[idx] = h5_strdup(item)); l->num_items++; - H5_PRIV_API_RETURN (idx); + H5_RETURN (idx); } /* @@ -101,7 +103,7 @@ h5priv_find_strlist ( ) { H5_PRIV_API_ENTER (ssize_t, "list=%p, item=%s", list, item); if (!list) { - H5_PRIV_API_LEAVE (-1); + H5_LEAVE (-1); } register h5_loc_idx_t low = 0; register h5_loc_idx_t high = list->num_items - 1; @@ -115,9 +117,9 @@ h5priv_find_strlist ( else if ( diff < 0 ) low = mid + 1; else - H5_PRIV_API_LEAVE (mid); // found + H5_LEAVE (mid); // found } - H5_PRIV_API_RETURN (-(low+1)); // not found + H5_RETURN (-(low+1)); // not found } /* @@ -134,7 +136,7 @@ h5priv_search_strlist ( idx = -(idx+1); TRY (idx = h5priv_insert_strlist (list, item, idx)); } - H5_PRIV_API_RETURN (idx); + H5_RETURN (idx); } h5_err_t @@ -144,14 +146,14 @@ h5priv_remove_strlist ( ) { H5_PRIV_API_ENTER (h5_err_t, "list=%p, item=%s", list, item); ssize_t idx = h5priv_find_strlist (list, item); - if (idx < 0) H5_PRIV_API_LEAVE (-1); + if (idx < 0) H5_LEAVE (-1); list->num_items--; memmove ( &list->items[idx], &list->items[idx+1], (list->num_items - idx) * sizeof (list->items[0])); - H5_PRIV_API_RETURN (idx); + H5_RETURN (idx); } @@ -168,7 +170,7 @@ h5priv_new_idxmap ( TRY (map->items = h5_calloc (size, sizeof (map->items[0]))); map->size = size; map->num_items = 0; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -183,13 +185,13 @@ h5priv_insert_idxmap ( (long long unsigned)glb_idx, (long long unsigned)loc_idx); if (map->num_items == map->size) - H5_PRIV_API_LEAVE ( + H5_LEAVE ( HANDLE_H5_OVERFLOW_ERR ( (long long)map->size)); h5_loc_idx_t i = h5priv_search_idxmap (map, glb_idx); if (i >= 0) /* global id already in use ? */ - H5_PRIV_API_LEAVE (-1); + H5_LEAVE (-1); i = -(i+1); @@ -201,7 +203,7 @@ h5priv_insert_idxmap ( map->items[i].loc_idx = loc_idx; map->num_items++; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -232,9 +234,9 @@ h5priv_search_idxmap ( else if ( diff < 0 ) low = mid + 1; else - H5_PRIV_API_LEAVE (mid); // found + H5_LEAVE (mid); // found } - H5_PRIV_API_RETURN (-(low+1)); // not found + H5_RETURN (-(low+1)); // not found } //static int @@ -265,5 +267,5 @@ h5priv_sort_idxmap ( H5_PRIV_API_ENTER (h5_err_t, "map=%p", map); qsort ( map->items, map->num_items, sizeof (map->items[0]), cmp_idxmap_items); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5_maps.h b/src/h5core/private/h5_maps.h index 9529f99..3523f9a 100644 --- a/src/h5core/private/h5_maps.h +++ b/src/h5core/private/h5_maps.h @@ -16,6 +16,8 @@ #include "h5core/h5_syscall.h" #include "private/h5_log.h" +#include + // Allocate new list #define h5priv_alloc_xlist( type ) \ static inline h5_err_t \ @@ -27,7 +29,7 @@ TRY (*list = h5_calloc ( \ 1, sizeof (**list)+size*sizeof ((*list)->items[0]))); \ (*list)->size = size; \ - H5_PRIV_API_RETURN (H5_SUCCESS); \ + H5_RETURN (H5_SUCCESS); \ } // Free list @@ -37,10 +39,10 @@ h5_ ## type ## list_t**list \ ) { \ H5_PRIV_API_ENTER (h5_err_t, "list=%p", list); \ - if (*list == NULL) H5_PRIV_API_LEAVE (H5_SUCCESS); \ + if (*list == NULL) H5_LEAVE (H5_SUCCESS); \ TRY (h5_free (*list)); \ *list = NULL; \ - H5_PRIV_API_RETURN (H5_SUCCESS); \ + H5_RETURN (H5_SUCCESS); \ } // Insert item @@ -80,7 +82,7 @@ } \ l->items[idx] = id; \ l->num_items++; \ - H5_PRIV_API_RETURN (idx); \ + H5_RETURN (idx); \ } /* @@ -100,7 +102,7 @@ "list=%p, item=%llu", \ list, (long long unsigned)item); \ if (!list) { \ - H5_PRIV_API_LEAVE (-1); \ + H5_LEAVE (-1); \ } \ register ssize_t low = 0; \ register ssize_t mid; \ @@ -112,9 +114,9 @@ else if (list->items[mid] < item) \ low = mid + 1; \ else \ - H5_PRIV_API_LEAVE (mid); \ + H5_LEAVE (mid); \ } \ - H5_PRIV_API_RETURN (-(low+1)); \ + H5_RETURN (-(low+1)); \ } @@ -134,7 +136,7 @@ idx = -(idx+1); \ TRY (idx = h5priv_insert_into_ ## type ## list (list, item, idx)); \ } \ - H5_PRIV_API_RETURN (idx); \ + H5_RETURN (idx); \ } @@ -184,13 +186,13 @@ h5priv_grow_idxmap ( "map=%p, size=%llu", map, (long long unsigned)size); if (map->num_items >= size) - H5_PRIV_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); int new = (map->items == NULL); size_t size_in_bytes = size * sizeof (map->items[0]); TRY (map->items = h5_alloc (map->items, size_in_bytes)); map->size = size; if (new) map->num_items = 0; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t diff --git a/src/h5core/private/h5_model.h b/src/h5core/private/h5_model.h index 97e9278..407357f 100644 --- a/src/h5core/private/h5_model.h +++ b/src/h5core/private/h5_model.h @@ -48,7 +48,7 @@ h5priv_start_throttle ( h5_warn ( "Throttling is only permitted with the MPI-POSIX " "or MPI-IO Independent VFD." ); - H5_CORE_API_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); } int token = 1; @@ -71,7 +71,7 @@ h5priv_start_throttle ( } h5_debug ("throttle: received token"); } - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -96,7 +96,7 @@ h5priv_end_throttle ( )); } } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #else // PARALLEL_IO static inline h5_err_t @@ -169,12 +169,12 @@ h5priv_map_enum_to_normalized_type ( ret_value = H5_FLOAT64; break; default: - H5_PRIV_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Unknown type %d", (int)type)); } - H5_PRIV_API_RETURN (ret_value); + H5_RETURN (ret_value); } /* @@ -227,12 +227,15 @@ h5priv_normalize_type ( ret_value = H5_STRING; break; default: - H5_PRIV_API_LEAVE ( + break; + } + if (ret_value < 0) { + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Unknown type %d", (int)type)); } - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } /* @@ -271,6 +274,8 @@ h5priv_map_hdf5_type_to_enum ( } else { ret_value = H5_UINT16_T; } + } else { + ret_value = H5_STRING_T; } break; case H5T_FLOAT: @@ -285,12 +290,12 @@ h5priv_map_hdf5_type_to_enum ( ret_value = H5_STRING_T; break; default: - H5_PRIV_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Unknown type %d", (int)type)); } - H5_CORE_API_RETURN (ret_value); + H5_RETURN (ret_value); } @@ -303,7 +308,7 @@ h5priv_get_normalized_dataset_type ( (long long)dataset); TRY (ret_value = hdf5_get_dataset_type (dataset)); TRY (ret_value = h5priv_normalize_type (ret_value)); - H5_PRIV_API_RETURN (ret_value); + H5_RETURN (ret_value); } #endif diff --git a/src/h5core/private/h5_mpi.h b/src/h5core/private/h5_mpi.h index 028e138..13d2473 100644 --- a/src/h5core/private/h5_mpi.h +++ b/src/h5core/private/h5_mpi.h @@ -16,6 +16,9 @@ #include "h5core/h5_err.h" #include "private/h5_log.h" +#define MPI_WRAPPER_ENTER(type, fmt, ...) \ + __FUNC_ENTER(type, H5_DEBUG_MPI, fmt, __VA_ARGS__ ) + static inline h5_err_t h5priv_mpi_alltoall ( void* sendbuf, @@ -39,11 +42,11 @@ h5priv_mpi_alltoall ( recvtype, comm); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_MPI, "Cannot perform all to all communication")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -75,11 +78,11 @@ h5priv_mpi_alltoallv ( recvtype, comm); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_MPI, "Cannot perform all to all communication")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } // barrier @@ -90,11 +93,11 @@ h5priv_mpi_barrier ( MPI_WRAPPER_ENTER (h5_err_t, "comm=%p",&comm); int err = MPI_Barrier(comm); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_MPI, "MPI Barrier was not successful")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } // communication routines @@ -120,8 +123,8 @@ h5priv_mpi_recv( MPI_STATUS_IGNORE ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot receive data")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot receive data")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -145,8 +148,8 @@ h5priv_mpi_send( comm ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot send data")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot send data")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -168,8 +171,8 @@ h5priv_mpi_bcast ( comm ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform broadcast")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform broadcast")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -192,8 +195,8 @@ h5priv_mpi_sum ( comm ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform MPI_SUM reduction")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform MPI_SUM reduction")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -215,9 +218,9 @@ h5priv_mpi_allreduce_max ( MPI_MAX, comm ) != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform MPI_MAX reduction")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -240,8 +243,8 @@ h5priv_mpi_prefix_sum ( comm ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform prefix sum")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot perform prefix sum")); + H5_RETURN (H5_SUCCESS); } #define h5priv_mpi_allgather mpi_allgather @@ -268,8 +271,8 @@ mpi_allgather ( recvtype, comm); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data")); + H5_RETURN (H5_SUCCESS); } #define h5priv_mpi_allgatherv mpi_allgatherv static inline h5_err_t @@ -298,8 +301,8 @@ mpi_allgatherv ( recvtype, comm); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot gather data")); + H5_RETURN (H5_SUCCESS); } /// @@ -311,8 +314,8 @@ 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) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot get communicator size")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot get communicator size")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -323,8 +326,8 @@ 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) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot get this task's rank")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot get this task's rank")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -339,11 +342,11 @@ h5priv_mpi_type_contiguous ( int err; err = MPI_Type_contiguous ( nelems, oldtype, newtype ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot create new MPI type")); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot create new MPI type")); err = MPI_Type_commit ( newtype ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error (H5_ERR_MPI, "Cannot commit new MPI type")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error (H5_ERR_MPI, "Cannot commit new MPI type")); + H5_RETURN (H5_SUCCESS); } #define h5priv_mpi_get_address mpi_get_address @@ -355,12 +358,12 @@ 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) { - MPI_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_MPI, "Cannot get MPI address of location=%p", location)); } - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #define h5priv_mpi_create_type_struct mpi_create_type_struct @@ -377,12 +380,12 @@ 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) { - MPI_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_MPI, "Cannot create new MPI struct")); } - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -392,12 +395,12 @@ h5priv_mpi_type_commit ( MPI_WRAPPER_ENTER (h5_err_t, "type=%p", type); int err = MPI_Type_commit (type); if (err != MPI_SUCCESS) { - MPI_WRAPPER_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_MPI, "Cannot commit MPI datatype")); } - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -408,8 +411,8 @@ h5priv_mpi_type_free ( MPI_WRAPPER_ENTER (h5_err_t, "type=%p", type); int err = MPI_Type_free( type ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error(H5_ERR_MPI, "Cannot free MPI type")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot free MPI type")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -427,8 +430,8 @@ h5priv_mpi_cart_create ( int err = MPI_Cart_create( old_comm, ndims, dims, period, reorder, new_comm); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid")); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -442,8 +445,8 @@ h5priv_mpi_cart_coords ( rank, maxdim, coords); int err = MPI_Cart_coords( comm, rank, maxdim, coords ); if (err != MPI_SUCCESS) - MPI_WRAPPER_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid")); - MPI_WRAPPER_RETURN (H5_SUCCESS); + H5_LEAVE (h5_error(H5_ERR_MPI, "Cannot create cartesian grid")); + H5_RETURN (H5_SUCCESS); } #endif diff --git a/src/h5core/private/h5t_access_tetm.c b/src/h5core/private/h5t_access_tetm.c index e3c96e0..3cf0fa2 100644 --- a/src/h5core/private/h5t_access_tetm.c +++ b/src/h5core/private/h5t_access_tetm.c @@ -17,6 +17,9 @@ #include "private/h5t_model.h" #include "private/h5t_access.h" +#include +#include + /*** op's on local elements ***/ #if defined(WITH_PARALLEL_H5GRID) @@ -182,7 +185,7 @@ alloc_glb_elems ( H5_PRIV_FUNC_ENTER (h5_glb_elem_p, "m=%p, size=%zu", m, size); h5_glb_elem_p buf; TRY (buf = h5_calloc (size, sizeof(h5_glb_tet_t))); - H5_PRIV_FUNC_RETURN (buf); + H5_RETURN (buf); } static h5_glb_elem_t* @@ -664,27 +667,27 @@ get_loc_entity_children ( const h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); if (h5tpriv_is_leaf_elem (m, &((h5_loc_tet_t*)m->loc_elems)[elem_idx])) { - H5_PRIV_FUNC_LEAVE (H5_NOK); // not refined + H5_LEAVE (H5_NOK); // not refined } switch (type_id) { case H5T_TYPE_TET: { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( get_children_of_loc_elem (m, face_idx, elem_idx, children)); break; } case H5T_TYPE_TRIANGLE: { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( get_children_of_loc_triangle (m, face_idx, elem_idx, children)); break; } case H5T_TYPE_EDGE: { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( get_children_of_loc_edge (m, face_idx, elem_idx, children)); } default: - H5_PRIV_FUNC_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } struct h5t_access_methods h5tpriv_access_tetm_methods = { diff --git a/src/h5core/private/h5t_access_trim.c b/src/h5core/private/h5t_access_trim.c index 2df6610..ee118b6 100644 --- a/src/h5core/private/h5t_access_trim.c +++ b/src/h5core/private/h5t_access_trim.c @@ -16,6 +16,9 @@ #include "private/h5t_model.h" #include "private/h5t_access.h" +#include +#include + #if defined(WITH_PARALLEL_H5GRID) static MPI_Datatype get_mpi_type_of_glb_elem ( @@ -180,7 +183,7 @@ alloc_glb_elems ( H5_PRIV_FUNC_ENTER (h5_glb_elem_p, "m=%p, size=%zu", m, size); h5_glb_elem_p buf; TRY (buf = h5_calloc (size, sizeof(h5_glb_tri_t))); - H5_PRIV_FUNC_RETURN (buf); + H5_RETURN (buf); } static h5_glb_elem_t* @@ -371,20 +374,20 @@ get_loc_entity_children ( const h5_loc_idx_t elem_idx = h5tpriv_get_elem_idx (entity_id); if (h5tpriv_is_leaf_elem (m, &((h5_loc_tri_t*)m->loc_elems)[elem_idx])) { - H5_PRIV_FUNC_LEAVE (H5_NOK); // not refined + H5_LEAVE (H5_NOK); // not refined } switch (type_id) { case H5T_TYPE_TRIANGLE: { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( get_children_of_loc_elem (m, face_idx, elem_idx, children)); break; } case H5T_TYPE_EDGE: { - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( get_children_of_loc_edge (m, face_idx, elem_idx, children)); } } - H5_PRIV_FUNC_RETURN (h5_error_internal ()); + H5_RETURN (h5_error_internal ()); } struct h5t_access_methods h5tpriv_access_trim_methods = { diff --git a/src/h5core/private/h5t_adjacencies.h b/src/h5core/private/h5t_adjacencies.h index f1e5eb9..e526f9f 100644 --- a/src/h5core/private/h5t_adjacencies.h +++ b/src/h5core/private/h5t_adjacencies.h @@ -34,9 +34,9 @@ h5tpriv_get_adjacencies ( "m=%p, entity_id=%lld, dim=%d, list=%p", m, (long long)entity_id, dim, list); if (m->methods->adjacency == NULL) { - H5_PRIV_API_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } - H5_PRIV_API_RETURN (m->methods->adjacency->get_adjacencies( + H5_RETURN (m->methods->adjacency->get_adjacencies( m, entity_id, dim, list)); } diff --git a/src/h5core/private/h5t_adjacencies_tetm.c b/src/h5core/private/h5t_adjacencies_tetm.c index a59953d..5f842f4 100644 --- a/src/h5core/private/h5t_adjacencies_tetm.c +++ b/src/h5core/private/h5t_adjacencies_tetm.c @@ -69,7 +69,7 @@ get_descendant_of_edge ( TRY( get_descendant_of_edge (m, edge_ids[1], children) ); } } while (++edge_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -100,7 +100,7 @@ get_sections_of_edge ( if (!refined) { TRY( h5priv_insert_into_loc_idlist (children, te->items[0], -1) ); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -131,7 +131,7 @@ get_descendant_of_triangle ( TRY (get_descendant_of_triangle (m, triangle_ids[3], children)); } } while (++triangle_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -164,7 +164,7 @@ get_sections_of_triangle ( if (!refined) { TRY( h5priv_insert_into_loc_idlist (children, td->items[0], -1) ); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -185,7 +185,7 @@ add_vertex2 ( h5_loc_idlist_t* tv; TRY( h5tpriv_find_tv2 (m, face_idx, elem_idx, &tv) ); TRY( h5priv_search_in_loc_idlist (list, tv->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -204,7 +204,7 @@ add_edge ( h5_loc_idlist_t* te = NULL; TRY( h5tpriv_find_te (m, entity_id, &te) ); TRY( h5priv_search_in_loc_idlist (list, te->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -222,7 +222,7 @@ add_edge2 ( h5_loc_idlist_t* te; TRY( h5tpriv_find_te2 (m, face_idx, elem_idx, &te) ); TRY( h5priv_search_in_loc_idlist (list, te->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -242,7 +242,7 @@ add_triangle ( TRY( h5tpriv_find_td (m, entity_id, &td) ); TRY( h5priv_search_in_loc_idlist (list, td->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -261,7 +261,7 @@ add_triangle2 ( TRY( h5tpriv_find_td2 (m, face_idx, elem_idx, &td) ); TRY( h5priv_search_in_loc_idlist (list, td->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -276,7 +276,7 @@ add_elem2 ( h5_loc_id_t elem_id = h5tpriv_build_tet_id ((h5_loc_idx_t)0, elem_idx); TRY( h5priv_search_in_loc_idlist (list, elem_id) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -319,7 +319,7 @@ get_edges_uadj_to_vertex ( m, 0, face_idx, 2), elem_idx) ); } while (++vertex_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -362,7 +362,7 @@ get_triangles_uadj_to_vertex ( m, 0, face_idx, 2), elem_idx) ); } while (++vertex_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -389,7 +389,7 @@ get_tets_uadj_to_vertex ( } TRY( add_elem2 (list, elem_idx) ); } while (++vertex_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -421,7 +421,7 @@ get_triangles_uadj_to_edge ( } while (++edge_idp < end); TRY (h5priv_free_loc_idlist (&children)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -443,7 +443,7 @@ get_tets_uadj_to_edge ( TRY( add_elem2 (list, h5tpriv_get_elem_idx (*edge_idp)) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -465,7 +465,7 @@ get_tets_uadj_to_triangle ( TRY( add_elem2 (list, h5tpriv_get_elem_idx (*triangle_idp)) ); } while (++triangle_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -498,7 +498,7 @@ get_vertices_dadj_to_edge ( elem_idx) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist(&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -545,7 +545,7 @@ get_vertices_dadj_to_triangle ( elem_idx) ); } while (++edge_idp < end ); TRY( h5priv_free_loc_idlist(&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -589,7 +589,7 @@ get_vertices_dadj_to_tet ( elem_idx) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist(&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -624,7 +624,7 @@ get_edges_dadj_to_triangle ( TRY( add_edge (m, list, *edge_idp) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -656,7 +656,7 @@ get_edges_dadj_to_tet ( TRY( add_edge (m, list, *edge_idp) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -686,7 +686,7 @@ get_triangles_dadj_to_tet ( TRY( add_triangle (m, list, *triangle_idp) ); } while (++triangle_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t diff --git a/src/h5core/private/h5t_adjacencies_trim.c b/src/h5core/private/h5t_adjacencies_trim.c index a7545b0..760d745 100644 --- a/src/h5core/private/h5t_adjacencies_trim.c +++ b/src/h5core/private/h5t_adjacencies_trim.c @@ -48,7 +48,7 @@ get_descendant_of_edge ( } } while (++edge_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -79,7 +79,7 @@ get_sections_of_edge ( if (!refined) { TRY (h5priv_insert_into_loc_idlist (children, te->items[0], -1)); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -100,7 +100,7 @@ add_vertex2 ( h5_loc_idlist_t* tv; TRY( h5tpriv_find_tv2 (m, face_idx, elem_idx, &tv) ); TRY( h5priv_search_in_loc_idlist (list, tv->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -119,7 +119,7 @@ add_edge ( h5_loc_idlist_t* te; TRY( h5tpriv_find_te (m, entity_id, &te) ); TRY( h5priv_search_in_loc_idlist (list, te->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -137,7 +137,7 @@ add_edge2 ( h5_loc_idlist_t *te; TRY( h5tpriv_find_te2 (m, face_idx, elem_idx, &te) ); TRY( h5priv_search_in_loc_idlist (list, te->items[0]) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -152,7 +152,7 @@ add_elem2 ( h5_loc_id_t elem_id = h5tpriv_build_triangle_id ((h5_loc_idx_t)0, elem_idx); TRY( h5priv_search_in_loc_idlist (list, elem_id) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -191,7 +191,7 @@ get_edges_uadj_to_vertex ( m, 0, face_idx, 1), elem_idx) ); } while (++vertex_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -219,7 +219,7 @@ get_triangles_uadj_to_vertex ( } TRY (add_elem2 (list, elem_idx)); } while (++vertex_idp < end); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -243,7 +243,7 @@ get_triangles_uadj_to_edge ( } while (++edge_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -267,7 +267,7 @@ get_edges_adj_to_edge ( TRY( add_edge (m, list, *edge_idp) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist(&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -299,7 +299,7 @@ get_vertices_dadj_to_edge ( elem_idx) ); } while (++edge_idp < end); TRY( h5priv_free_loc_idlist (&children) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -344,7 +344,7 @@ get_vertices_dadj_to_triangle ( elem_idx) ); } while (++edge_idp < end); TRY (h5priv_free_loc_idlist(&children)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -374,7 +374,7 @@ get_edges_dadj_to_triangle ( TRY( add_edge (m, list, *edge_idp) ); } while (++edge_idp < end); TRY (h5priv_free_loc_idlist(&children)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t diff --git a/src/h5core/private/h5t_core.c b/src/h5core/private/h5t_core.c index 0de096d..a74d359 100644 --- a/src/h5core/private/h5t_core.c +++ b/src/h5core/private/h5t_core.c @@ -46,7 +46,7 @@ h5tpriv_enter_tv2 ( *idlist = m->adjacencies.tv.v[vertex_idx]; } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -92,7 +92,7 @@ h5tpriv_enter_te2 ( if (idlist) { *idlist = te_entry->value; } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -138,7 +138,7 @@ h5tpriv_enter_td2 ( if (idlist) { *idlist = td_entry->value; } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static int @@ -178,7 +178,7 @@ release_te_entry ( h5_loc_idlist_t* list = entry->value; TRY (h5priv_free_loc_idlist (&list)); TRY (h5_free (entry)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -199,7 +199,7 @@ h5tpriv_grow_te_htab ( } else { TRY (h5priv_hgrow (nel, &a->te_hash)); } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -223,12 +223,12 @@ find_te ( &m->adjacencies.te_hash)); h5t_te_entry_t* entry = (h5t_te_entry_t*)__entry; if (entry == NULL) { - H5_PRIV_FUNC_LEAVE (H5_NOK); // not found + H5_LEAVE (H5_NOK); // not found } if (idlist) { *idlist = entry->value; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -252,7 +252,7 @@ h5tpriv_find_te ( item.key.vids)); TRY (find_te (m, &item, idlist)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -272,7 +272,7 @@ h5tpriv_find_te2 ( elem_idx, item.key.vids)); TRY (find_te (m, &item, idlist)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static int @@ -312,7 +312,7 @@ release_td_entry ( h5_loc_idlist_t* list = entry->value; TRY (h5priv_free_loc_idlist (&list)); TRY (h5_free (entry)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -334,7 +334,7 @@ h5tpriv_grow_td_htab ( } else { TRY (h5priv_hgrow (nel, &a->td_hash)); } - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -372,7 +372,7 @@ h5tpriv_find_td ( triangle_id, item.key.vids)); TRY (find_td (m, &item, idlist)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -392,7 +392,7 @@ h5tpriv_find_td2 ( elem_idx, item.key.vids)); TRY (find_td (m, &item, idlist)); - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -411,7 +411,7 @@ h5tpriv_find_tv2 ( h5_loc_idx_t idx; TRY (idx = h5tpriv_get_loc_elem_vertex_idx (m, elem_idx, face_idx)); *idlist = m->adjacencies.tv.v[idx]; - H5_PRIV_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -427,5 +427,5 @@ h5tpriv_find_tv3 ( "m=%p, vtx_idx=%lld, idlist=%p", m, (long long)vtx_idx, idlist); *idlist = m->adjacencies.tv.v[vtx_idx]; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5t_core.h b/src/h5core/private/h5t_core.h index 398b89e..5252f39 100644 --- a/src/h5core/private/h5t_core.h +++ b/src/h5core/private/h5t_core.h @@ -192,9 +192,9 @@ h5tpriv_release_adjacency_structs ( ) { H5_PRIV_API_ENTER (h5_err_t, "m=%p", m); if (m->methods->adjacency == NULL) { - H5_PRIV_API_LEAVE (H5_OK); + H5_LEAVE (H5_OK); } - H5_PRIV_API_RETURN (m->methods->core->release_internal_structs(m)); + H5_RETURN (m->methods->core->release_internal_structs(m)); } static inline h5_err_t @@ -204,9 +204,9 @@ h5tpriv_update_internal_structs ( ) { H5_PRIV_API_ENTER (h5_err_t, "m=%p, level_id=%d", m, level_id); if (m->methods->adjacency == NULL) { - H5_PRIV_API_LEAVE (H5_OK); + H5_LEAVE (H5_OK); } - H5_PRIV_API_RETURN (m->methods->core->update_internal_structs(m, level_id)); + H5_RETURN (m->methods->core->update_internal_structs(m, level_id)); } #endif diff --git a/src/h5core/private/h5t_core_tetm.c b/src/h5core/private/h5t_core_tetm.c index 2df250d..dca7121 100644 --- a/src/h5core/private/h5t_core_tetm.c +++ b/src/h5core/private/h5t_core_tetm.c @@ -179,7 +179,7 @@ alloc_tv ( size_t i = from_lvl <= 0 ? 0 : m->num_loc_vertices[from_lvl-1]; memset (adj->tv.v+i, 0, (num_loc_vertices-i)*sizeof(*adj->tv.v)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -246,7 +246,7 @@ update_internal_structs ( TRY (h5tpriv_enter_td2 (m, face_idx, elem_idx, NULL)); } } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -259,7 +259,7 @@ release_tv ( H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); h5t_adjacencies_t* adj = &m->adjacencies; if (adj->tv.v == NULL) - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); h5_loc_idx_t vertex_idx = 0; h5_loc_idx_t last = m->num_loc_vertices[m->num_loaded_levels-1]; @@ -268,7 +268,7 @@ release_tv ( } TRY( h5_free (adj->tv.v) ); adj->tv.v = NULL; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -280,7 +280,7 @@ release_internal_structs ( TRY( h5priv_hdestroy (&m->adjacencies.te_hash) ); TRY( h5priv_hdestroy (&m->adjacencies.td_hash) ); memset (&m->adjacencies, 0, sizeof (m->adjacencies)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } struct h5t_core_methods h5tpriv_tetm_core_methods = { diff --git a/src/h5core/private/h5t_core_trim.c b/src/h5core/private/h5t_core_trim.c index 501a631..b1f7255 100644 --- a/src/h5core/private/h5t_core_trim.c +++ b/src/h5core/private/h5t_core_trim.c @@ -142,7 +142,7 @@ alloc_tv ( size_t i = from_lvl <= 0 ? 0 : m->num_loc_vertices[from_lvl-1]; memset (adj->tv.v+i, 0, (num_loc_vertices-i)*sizeof(*adj->tv.v)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -237,7 +237,7 @@ update_internal_structs ( } } #endif - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -247,7 +247,7 @@ release_tv ( H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); h5t_adjacencies_t* adj = &m->adjacencies; if (adj->tv.v == NULL) - H5_PRIV_FUNC_LEAVE (H5_SUCCESS); + H5_LEAVE (H5_SUCCESS); h5_loc_idx_t vertex_idx = 0; h5_loc_idx_t last = m->num_loc_vertices[m->num_loaded_levels-1]; @@ -256,7 +256,7 @@ release_tv ( } TRY( h5_free (adj->tv.v) ); adj->tv.v = NULL; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static inline h5_err_t @@ -267,7 +267,7 @@ release_internal_structs ( TRY( release_tv (m) ); TRY( h5priv_hdestroy (&m->adjacencies.te_hash) ); memset (&m->adjacencies, 0, sizeof (m->adjacencies)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } struct h5t_core_methods h5tpriv_trim_core_methods = { diff --git a/src/h5core/private/h5t_io.h b/src/h5core/private/h5t_io.h index db8406a..f5b0928 100644 --- a/src/h5core/private/h5t_io.h +++ b/src/h5core/private/h5t_io.h @@ -114,17 +114,11 @@ h5tpriv_get_list_of_chunks_to_read ( ); h5_int32_t -find_proc_to_write ( +h5priv_find_proc_to_write ( h5t_mesh_t* const m, h5_loc_idx_t elem_idx ); -//TODO this is a bugfix remove after xfer_prop fix has been done! -void -set_xfer_prop_to (const h5_file_p file, hid_t prop); -void -set_xfer_prop_to2 (h5t_mesh_t* const m, hid_t prop); - // TODO move this to appropriate place typedef struct { int (*compare) (const void *p_a, const void *p_b); diff --git a/src/h5core/private/h5t_io_tetm.c b/src/h5core/private/h5t_io_tetm.c index 7649f68..c6488b0 100644 --- a/src/h5core/private/h5t_io_tetm.c +++ b/src/h5core/private/h5t_io_tetm.c @@ -76,7 +76,7 @@ init_loc_elems_struct ( num_facets, loc_elem->neighbor_indices); } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } #define H5_LOC_ELEM_T h5_loc_tet_t @@ -126,7 +126,7 @@ init_elem_flags ( } elem++; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -156,7 +156,7 @@ init_map_elem_g2l ( } h5priv_sort_idxmap (map); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -189,7 +189,7 @@ init_glb_elems_struct ( loc_elem++; glb_elem++; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -200,9 +200,9 @@ init_glb_elems_struct_chk ( int num_chk ) { H5_PRIV_FUNC_ENTER (h5_err_t, "m=%p", m); - H5_PRIV_FUNC_LEAVE (H5_ERR_NOT_IMPLEMENTED); + H5_LEAVE (H5_ERR_NOT_IMPLEMENTED); // TODO just copy from readwrite_trim and replace 3 indices with 4... - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } struct h5t_read_methods h5tpriv_read_tetm_methods = { diff --git a/src/h5core/private/h5t_io_trim.c b/src/h5core/private/h5t_io_trim.c index b24fae0..748360c 100644 --- a/src/h5core/private/h5t_io_trim.c +++ b/src/h5core/private/h5t_io_trim.c @@ -83,7 +83,7 @@ init_loc_elems_struct ( } m->last_stored_eid = from_idx + count -1; - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -124,7 +124,7 @@ init_elem_flags ( } elem++; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } static h5_err_t @@ -151,7 +151,7 @@ init_map_elem_g2l ( } h5priv_sort_idxmap (map); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -184,7 +184,7 @@ init_glb_elems_struct ( loc_elem++; glb_elem++; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } //TODO maybe use ifdef to have name without _chk @@ -239,7 +239,7 @@ init_glb_elems_struct_chk ( } #endif - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5t_map.h b/src/h5core/private/h5t_map.h index ada0684..7b524ab 100644 --- a/src/h5core/private/h5t_map.h +++ b/src/h5core/private/h5t_map.h @@ -32,7 +32,7 @@ "list=%p, item=%llu", \ list, (long long unsigned)item); \ if (!list) { \ - H5_PRIV_API_LEAVE (-1); \ + H5_LEAVE (-1); \ } \ register ssize_t low = 0; \ register ssize_t mid; \ @@ -51,9 +51,9 @@ else if ( diff < 0 ) \ low = mid + 1; \ else \ - H5_PRIV_API_LEAVE (mid); \ + H5_LEAVE (mid); \ } \ - H5_PRIV_API_RETURN (-(low+1)); \ + H5_RETURN (-(low+1)); \ } diff --git a/src/h5core/private/h5t_model_tetm.c b/src/h5core/private/h5t_model_tetm.c index 7335970..b3261ca 100644 --- a/src/h5core/private/h5t_model_tetm.c +++ b/src/h5core/private/h5t_model_tetm.c @@ -55,7 +55,7 @@ h5t_open_tetrahedral_mesh_by_idx ( TRY (hdf5_get_name_of_group_by_idx (ctn_hid, idx, name, sizeof (name))); TRY (hdf5_close_group (ctn_hid)); - H5_CORE_API_RETURN (h5t_open_tetrahedral_mesh ((h5_file_t)f, name, mesh)); + H5_RETURN (h5t_open_tetrahedral_mesh ((h5_file_t)f, name, mesh)); } h5_err_t @@ -92,7 +92,7 @@ h5t_open_tetrahedral_mesh ( #else TRY (h5tpriv_read_mesh (m)); #endif - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } h5_err_t @@ -126,7 +126,7 @@ h5t_open_tetrahedral_mesh_part ( 0)); TRY (h5tpriv_read_mesh_part (m, elem_indices, dim)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -151,7 +151,7 @@ h5t_add_tetrahedral_mesh ( TETRAHEDRAL_MESHES_GRPNAME, name)); if (exists) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR, "Tetrahedral mesh '%s' already exists!", @@ -183,7 +183,7 @@ h5t_add_tetrahedral_mesh ( TRY (h5tpriv_add_level (m)); m->mesh_changed = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -209,7 +209,7 @@ h5t_add_chunked_tetrahedral_mesh ( TETRAHEDRAL_MESHES_GRPNAME, name)); if (exists) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR, "Tetrahedral mesh '%s' already exists!", @@ -241,5 +241,5 @@ h5t_add_chunked_tetrahedral_mesh ( TRY (h5tpriv_add_level (m)); m->mesh_changed = 1; #endif - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5t_model_trim.c b/src/h5core/private/h5t_model_trim.c index 16256b1..cb3e88b 100644 --- a/src/h5core/private/h5t_model_trim.c +++ b/src/h5core/private/h5t_model_trim.c @@ -54,7 +54,7 @@ h5t_open_triangle_mesh_by_idx ( TRY (hdf5_get_name_of_group_by_idx (ctn_hid, idx, name, sizeof (name))); TRY (hdf5_close_group (ctn_hid)); - H5_CORE_API_RETURN (h5t_open_triangle_mesh ((h5_file_t)f, name, mesh)); + H5_RETURN (h5t_open_triangle_mesh ((h5_file_t)f, name, mesh)); } h5_err_t @@ -100,7 +100,7 @@ h5t_open_triangle_mesh ( m->is_chunked && m->f->nprocs > 1 ? h5tpriv_read_chunked_mesh (m) : h5tpriv_read_mesh (m) ); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -145,7 +145,7 @@ h5t_open_triangle_mesh_part ( TRY (h5tpriv_read_mesh_part (m, elem_indices, dim)); - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -170,7 +170,7 @@ h5t_add_triangle_mesh ( TRIANGLE_MESHES_GRPNAME, name)); if (exists) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR, "Tetrahedral mesh '%s' already exists!", @@ -201,7 +201,7 @@ h5t_add_triangle_mesh ( TRY (h5tpriv_add_level (m)); m->mesh_changed = 1; - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! Add new chunked mesh @@ -221,7 +221,7 @@ h5t_add_chunked_triangle_mesh( int size = -1; TRY (h5priv_mpi_comm_size (f->props->comm, &size)); if (size != 1) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR, "Trying to create a chunked mesh with '%d' procs instead of 1!", @@ -236,7 +236,7 @@ h5t_add_chunked_triangle_mesh( TRIANGLE_MESHES_GRPNAME, name)); if (exists) { - H5_CORE_API_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR, "Triangle mesh '%s' already exists!", @@ -268,5 +268,5 @@ h5t_add_chunked_triangle_mesh( TRY (h5tpriv_add_level (m)); m->mesh_changed = 1; #endif - H5_CORE_API_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } diff --git a/src/h5core/private/h5t_octree.h b/src/h5core/private/h5t_octree.h index d723467..55b3c7f 100644 --- a/src/h5core/private/h5t_octree.h +++ b/src/h5core/private/h5t_octree.h @@ -167,8 +167,8 @@ h5_oct_idx_t H5t_find_leafoctant_of_point (h5t_octree_t* octree, h5_oct_idx_t oc h5_oct_level_t H5t_oct_has_level (h5t_octree_t* octree, h5_oct_idx_t oct_idx, h5_oct_level_t level); // for debug purposes only -h5_err_t plot_octants (h5t_octree_t* octree); -h5_err_t plot_octant_anc (h5t_octree_t* octree, h5_oct_idx_t oct_idx); +h5_err_t h5priv_plot_octants (h5t_octree_t* octree); +h5_err_t h5priv_plot_octant_anc (h5t_octree_t* octree, h5_oct_idx_t oct_idx); h5_err_t plot_leaf_octants (h5t_octree_t* octree); void print_array (h5_int32_t* neigh, h5_oct_idx_t nbr_neigh, int rank); diff --git a/src/h5core/private/h5t_store_tetm.c b/src/h5core/private/h5t_store_tetm.c index 0dad247..69d4cae 100644 --- a/src/h5core/private/h5t_store_tetm.c +++ b/src/h5core/private/h5t_store_tetm.c @@ -36,7 +36,7 @@ alloc_loc_elems ( -1, (new-cur) * sizeof (h5_loc_tet_t) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } @@ -75,9 +75,9 @@ bisect_edge ( TRY( h5t_get_loc_vertex_indices_of_edge (m, kids[0], edge0) ); TRY( h5t_get_loc_vertex_indices_of_edge (m, kids[1], edge1) ); if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) { - H5_PRIV_FUNC_LEAVE (edge0[0]); // return first vertex + H5_LEAVE (edge0[0]); // return first vertex } else { - H5_PRIV_FUNC_LEAVE (edge0[1]); // return second vertex + H5_LEAVE (edge0[1]); // return second vertex } } } @@ -94,7 +94,7 @@ bisect_edge ( P[1] = (P0[1] + P1[1]) / 2.0; P[2] = (P0[2] + P1[2]) / 2.0; - H5_PRIV_FUNC_RETURN (h5t_store_vertex (m, -1, P)); // return idx of new vertex + H5_RETURN (h5t_store_vertex (m, -1, P)); // return idx of new vertex } /* @@ -128,7 +128,7 @@ pre_refine_tet ( unsigned int num_interior_elems_to_refine = m->marked_entities->num_items; TRY (h5t_begin_store_vertices (m, num_interior_elems_to_refine*3 + 192)); TRY (h5t_begin_store_elems (m, num_interior_elems_to_refine*8)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -151,7 +151,7 @@ refine_tet ( h5_loc_tet_t* el = (h5_loc_tet_t*)m->loc_elems + elem_idx; if ( el->child_idx >= 0 ) - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Tetrahedron %lld already refined.", @@ -256,7 +256,7 @@ refine_tet ( ((h5_loc_tet_t*)m->loc_elems)[elem_idx].child_idx = elem_idx_of_first_child; m->num_interior_leaf_elems[m->leaf_level]--; - H5_PRIV_FUNC_RETURN (elem_idx_of_first_child); + H5_RETURN (elem_idx_of_first_child); } static inline h5_loc_idx_t @@ -278,7 +278,7 @@ compute_neighbor_of_face ( elem_idx, &td) ); if (td == NULL) { - H5_PRIV_FUNC_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } if (td->num_items == 1) { // neighbor is coarser or face is on the boundary @@ -296,10 +296,10 @@ compute_neighbor_of_face ( } } else { - H5_PRIV_FUNC_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } } while (neighbor_idx < -1); - H5_PRIV_FUNC_RETURN (neighbor_idx); + H5_RETURN (neighbor_idx); } /* @@ -312,7 +312,7 @@ 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_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "level idx %lld out of bound, must be in [%lld,%lld]", @@ -333,7 +333,7 @@ compute_neighbors_of_elems ( el++; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * returns number of newly created tetrahedra when refining a tetrahedral @@ -357,7 +357,7 @@ end_store_elems ( TRY( h5tpriv_update_internal_structs (m, m->leaf_level) ); TRY( compute_neighbors_of_elems (m, m->leaf_level) ); TRY( h5tpriv_init_elem_flags (m, start_idx, count) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } struct h5t_store_methods h5tpriv_tetm_store_methods = { diff --git a/src/h5core/private/h5t_store_trim.c b/src/h5core/private/h5t_store_trim.c index b730144..4613847 100644 --- a/src/h5core/private/h5t_store_trim.c +++ b/src/h5core/private/h5t_store_trim.c @@ -36,7 +36,7 @@ alloc_loc_elems ( -1, (new-cur) * sizeof (h5_loc_tri_t)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* @@ -63,7 +63,7 @@ bisect_edge ( // for (int j = 0; j < num_b_edges; j++) { // if (b_edges[j].idx == my_glb_idx && // b_edges[j].face_idx == face_idx) { -// H5_PRIV_FUNC_LEAVE (b_edges[j].vtx); +// H5_LEAVE (b_edges[j].vtx); // } // } // } @@ -75,9 +75,9 @@ bisect_edge ( TRY (h5t_get_loc_vertex_indices_of_edge (m, kids[0], edge0)); TRY (h5t_get_loc_vertex_indices_of_edge (m, kids[1], edge1)); if ((edge0[0] == edge1[0]) || (edge0[0] == edge1[1])) { - H5_PRIV_FUNC_LEAVE (edge0[0]); + H5_LEAVE (edge0[0]); } else { - H5_PRIV_FUNC_LEAVE (edge0[1]); + H5_LEAVE (edge0[1]); } } } @@ -94,7 +94,7 @@ bisect_edge ( P[1] = (P0[1] + P1[1]) / 2.0; P[2] = (P0[2] + P1[2]) / 2.0; - H5_PRIV_FUNC_RETURN (h5t_store_vertex (m, -1, P)); + H5_RETURN (h5t_store_vertex (m, -1, P)); } /* @@ -109,7 +109,7 @@ pre_refine_triangle ( unsigned int num_interior_elems_to_refine = m->marked_entities->num_items; TRY (h5t_begin_store_vertices (m, num_interior_elems_to_refine*3 + 64)); TRY (h5t_begin_store_elems (m, num_interior_elems_to_refine*4)); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /*! @@ -130,7 +130,7 @@ refine_triangle ( h5_loc_tri_t* el = (h5_loc_tri_t*)m->loc_elems + elem_idx; if (el->child_idx >= 0) - H5_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "Element %lld already refined.", @@ -169,7 +169,7 @@ refine_triangle ( ((h5_loc_tri_t*)m->loc_elems)[elem_idx].child_idx = elem_idx_of_first_child; m->num_interior_leaf_elems[m->leaf_level]--; - H5_PRIV_FUNC_RETURN (elem_idx_of_first_child); + H5_RETURN (elem_idx_of_first_child); } static inline h5_loc_idx_t @@ -191,7 +191,7 @@ compute_neighbor_of_face ( elem_idx, &te) ); if (te == NULL) { - H5_PRIV_FUNC_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } if (te->num_items == 1) { h5_loc_idx_t old_elem_idx = elem_idx; @@ -207,8 +207,8 @@ compute_neighbor_of_face ( h5_debug ("Elem %d is on different proc than its parent %d \n" "therefore neighborhood idx is not correct resolved", old_elem_idx, elem_idx); } - assert (m->f->myproc != find_proc_to_write (m, old_elem_idx)); - H5_PRIV_FUNC_LEAVE (~0); //TODO what is a resonable output here? + assert (m->f->myproc != h5priv_find_proc_to_write (m, old_elem_idx)); + H5_LEAVE (~0); //TODO what is a resonable output here? } } else if (te->num_items == 2) { // neighbor has same level of coarsness @@ -220,10 +220,10 @@ compute_neighbor_of_face ( } else { printf ("elem %d face %d num_items %d", elem_idx, face_idx, te->num_items); - H5_PRIV_FUNC_LEAVE (h5_error_internal ()); + H5_LEAVE (h5_error_internal ()); } } while (neighbor_idx < -1); - H5_PRIV_FUNC_RETURN (neighbor_idx); + H5_RETURN (neighbor_idx); } /* @@ -236,7 +236,7 @@ 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_PRIV_FUNC_LEAVE ( + H5_LEAVE ( h5_error ( H5_ERR_INVAL, "level idx %lld out of bound, must be in [%lld,%lld]", @@ -257,7 +257,7 @@ compute_neighbors_of_elems ( el++; } - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } /* * returns number of newly created triangles when refining a triangle @@ -280,7 +280,7 @@ end_store_elems ( TRY( h5tpriv_update_internal_structs (m, m->leaf_level) ); TRY( compute_neighbors_of_elems (m, m->leaf_level) ); TRY( h5tpriv_init_elem_flags (m, start_idx, count) ); - H5_PRIV_FUNC_RETURN (H5_SUCCESS); + H5_RETURN (H5_SUCCESS); } struct h5t_store_methods h5tpriv_trim_store_methods = { diff --git a/src/include/h5core/h5_log.h b/src/include/h5core/h5_log.h index 118d4c6..350cdcb 100644 --- a/src/include/h5core/h5_log.h +++ b/src/include/h5core/h5_log.h @@ -81,16 +81,6 @@ extern struct call_stack h5_call_stack; extern "C" { #endif -static inline void -h5_call_stack_init ( - const char* fname, - enum h5_rtypes type - ) { - h5_call_stack.level = 0; - h5_call_stack.entry[0].name = (char *)fname; - h5_call_stack.entry[0].type = type; -} - static inline void h5_call_stack_push ( const char* fname, @@ -189,106 +179,6 @@ __attribute__ ((format (printf, 1, 2))) #endif ; -////////////////////////////////////////////////////////////////////////////// -// function enter macro -#if defined(NDEBUG) - -#define __API_ENTER(type, mask, fmt, ...) \ - h5_call_stack_init (__func__,e_##type); \ - type ret_value = (type)H5_ERR; - -#define __FUNC_ENTER(type, mask, fmt, ...) \ - type ret_value = (type)H5_ERR; - -#else // NDEBUG not defined - -#define __API_ENTER(type, mask, fmt, ...) \ - h5_call_stack_push (__func__,e_##type); \ - type ret_value = (type)H5_ERR; \ - if (h5_log_level & mask ) { \ - h5_debug ("(" fmt ")", __VA_ARGS__); \ - } - -#define __FUNC_ENTER(type, mask, fmt, ...) \ - type ret_value = (type)H5_ERR; \ - if (h5_log_level & mask ) { \ - h5_call_stack_push (__func__,e_##type); \ - h5_debug ("(" fmt ")", __VA_ARGS__); \ - } \ - -#endif -// -////////////////////////////////////////////////////////////////////////////// - -#define __API_LEAVE(expr) { \ - ret_value = expr; \ - goto done; \ - } - -#define __FUNC_LEAVE(expr) { \ - ret_value = expr; \ - goto done; \ -} - -////////////////////////////////////////////////////////////////////////////// -// function return macro -#if defined(NDEBUG) - -#define __API_RETURN(expr, mask) \ - ret_value = expr; \ - goto done; \ -done: \ - return ret_value; - -#define __FUNC_RETURN(expr, mask) \ - ret_value = expr; \ - goto done; \ -done: \ - return ret_value; - -#else // NDEBUG not defined - -#define __API_RETURN(expr, mask) \ - ret_value = expr; \ - goto done; \ -done: \ - if (h5_log_level & mask ) { \ - char fmt[256]; \ - snprintf (fmt, sizeof(fmt), "return: %s", \ - h5_rfmts[h5_call_stack_get_type()]); \ - h5_debug (fmt, ret_value); \ - } \ - h5_call_stack_reset (); \ - return ret_value; - -#define __FUNC_RETURN(expr, mask) \ - ret_value = expr; \ - goto done; \ -done: \ - if (h5_log_level & mask ) { \ - char fmt[256]; \ - snprintf (fmt, sizeof(fmt), "return: %s", \ - h5_rfmts[h5_call_stack_get_type()]); \ - h5_debug (fmt, ret_value); \ - h5_call_stack_pop(); \ - } \ - return ret_value; - -#endif -// -////////////////////////////////////////////////////////////////////////////// - -#define H5_API_ENTER(type, fmt, ...) \ - __API_ENTER(type, H5_DEBUG_API, fmt, __VA_ARGS__) -#define H5_API_LEAVE(expr) __API_LEAVE(expr) -#define H5_API_RETURN(expr) __API_RETURN(expr, H5_DEBUG_API); - - -#define TRY( func ) \ - if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) { \ - goto done; \ - } - h5_err_t h5_set_loglevel ( const h5_id_t); @@ -301,4 +191,70 @@ h5_get_loglevel ( } #endif +////////////////////////////////////////////////////////////////////////////// +// function enter macro +#if defined(NDEBUG) + +#define H5_API_ENTER(type, fmt, ...) \ + type ret_value = (type)H5_ERR; + +#else // NDEBUG not defined + +#define H5_API_ENTER(type, fmt, ...) \ + h5_call_stack_reset (); \ + type ret_value = (type)H5_ERR; \ + int __log__ = h5_log_level & H5_DEBUG_API; \ + if (__log__) { \ + h5_call_stack_push (__func__,e_##type); \ + h5_debug ("(" fmt ")", __VA_ARGS__); \ + } + +#endif +// +////////////////////////////////////////////////////////////////////////////// + +#define H5_LEAVE(expr) { \ + ret_value = expr; \ + goto done; \ +} + +////////////////////////////////////////////////////////////////////////////// +// function return macro +#if defined(NDEBUG) + +#define H5_RETURN(expr) \ + ret_value = expr; \ + goto done; \ +done: \ + return ret_value; + +#else // NDEBUG not defined + +#define H5_RETURN(expr) \ + ret_value = expr; \ + goto done; \ +done: \ +if (__log__ ) { \ + char fmt[256]; \ + snprintf (fmt, sizeof(fmt), "return: %s", \ + h5_rfmts[h5_call_stack_get_type()]); \ + h5_debug (fmt, ret_value); \ + h5_call_stack_pop(); \ + } \ + return ret_value; + +#endif +// +////////////////////////////////////////////////////////////////////////////// + +#define H5_API_LEAVE(expr) H5_LEAVE(expr) +#define H5_API_RETURN(expr) H5_RETURN(expr); + + +#define TRY( func ) \ + if ((int64_t)(ptrdiff_t)(func) <= (int64_t)H5_ERR) { \ + goto done; \ + } + + #endif diff --git a/src/include/h5core/h5_syscall.h b/src/include/h5core/h5_syscall.h index ecaf755..725292d 100644 --- a/src/include/h5core/h5_syscall.h +++ b/src/include/h5core/h5_syscall.h @@ -10,84 +10,16 @@ #ifndef __H5CORE_H5_SYSCALL_H #define __H5CORE_H5_SYSCALL_H -#include -#include - #include "h5core/h5_types.h" -#include "h5core/h5_log.h" - -#define MALLOC_WRAPPER_ENTER(type, fmt, ...) \ - __FUNC_ENTER(type, H5_DEBUG_MALLOC, fmt, __VA_ARGS__) -#define MALLOC_WRAPPER_LEAVE(value) __FUNC_LEAVE(value) -#define MALLOC_WRAPPER_RETURN(value) __FUNC_RETURN(value, H5_DEBUG_MALLOC) #ifdef __cplusplus extern "C" { #endif - -static inline h5_err_t -h5_free ( - void* ptr - ) { - MALLOC_WRAPPER_ENTER (h5_err_t, "ptr=%p", ptr); - if (ptr) { - free (ptr); - } - MALLOC_WRAPPER_RETURN (H5_SUCCESS); -} - - -static inline void_p -h5_alloc ( - void* ptr, - const size_t size - ) { - MALLOC_WRAPPER_ENTER (void_p, "ptr=%p, size=%lu", ptr, size); - if (size < 1) { - ret_value = (void_p) h5_free (ptr); - MALLOC_WRAPPER_LEAVE (NULL); - } - ptr = realloc (ptr, size); - if (ptr == NULL) { - MALLOC_WRAPPER_LEAVE ( - (void_p)h5_error (H5_ERR_NOMEM, "Out of memory. Tried to alloc %lld", (long long int)size)); - } - MALLOC_WRAPPER_RETURN (ptr); -} - -static inline void_p -h5_calloc ( - const size_t count, - const size_t size - ) { - MALLOC_WRAPPER_ENTER (void_p, "count=%zu , size=%zu", count, size); - void* ptr = NULL; - if (count * size < 1) { - MALLOC_WRAPPER_LEAVE (ptr); - } - ptr = calloc (count, size); - if (ptr == NULL) { - MALLOC_WRAPPER_LEAVE ( - (void_p)h5_error (H5_ERR_NOMEM, "Out of memory. Tried to alloc %lld", (long long int)count* size)); - } - MALLOC_WRAPPER_RETURN (ptr); -} - - -static inline char_p -h5_strdup ( - const char* s1 - ) { - MALLOC_WRAPPER_ENTER (char_p, "s='%s'", s1); - - char_p s2 = (char_p)h5_calloc (1, strlen (s1)+1 ); - if (s2 == NULL) { - MALLOC_WRAPPER_LEAVE ( - (char_p)h5_error (H5_ERR_NOMEM, "Out of memory.")); - } - MALLOC_WRAPPER_RETURN (strcpy (s2, s1)); -} + h5_err_t h5_free (void* ptr); + void_p h5_alloc (void* ptr, const size_t size); + void_p h5_calloc (const size_t count, const size_t size); + char_p h5_strdup (const char* s1); #ifdef __cplusplus }