From b227b388533896337f436f01763ad26def14844c Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Fri, 30 Jan 1998 14:25:44 -0500 Subject: [svn-r204] Changes since 19980129 ---------------------- ./RELEASE Added Library functions that I missed the first time. ./html/Datasets.html Added an example for Elena's question about how to read a single member of a compound data type so it becomes an array of that member in memory. ./src/H5Pprivate.h Fixed the prototype for H5P_get_hyperslab() to match the definition. ./src/H5Psimp.c Oops, added the kludge back in for the offset argument, which is still an `intn' instead of a `size_t'. ./src/H5.c ./src/H5public.h ./src/H5F.c ./src/H5T.c ./src/H5Tpublic.h Changed H5init() to H5open() and added an H5close() to fit our create/open/close paradigm. The H5open() happens automatically on the first call to the HDF5 library. The H5close() happens automatically on exit() (unless the app turns off that feature). H5close() closes all datasets and files and releases all resources used by the library. ./test/dsets.c Added calls to H5open() and H5close() to test them. ./test/dtypes.c Removed call to H5init() since we no longer need it there. ./src/H5Fstdio.c Changed the PABLO_MASK to the right value. Thanks Kim. --- RELEASE | 5 +++++ bin/checkposix | 4 ++-- src/H5.c | 37 ++++++++++++++++++++++++++++++---- src/H5F.c | 3 ++- src/H5Fstdio.c | 2 +- src/H5Pprivate.h | 2 +- src/H5Psimp.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5T.c | 26 ++++++++++++++++++++++++ src/H5Tpublic.h | 52 ++++++++++++++++++++++++------------------------ src/H5public.h | 3 ++- test/cmpd_dset.c | 1 - test/dsets.c | 7 +++++++ test/dtypes.c | 2 -- 13 files changed, 165 insertions(+), 39 deletions(-) diff --git a/RELEASE b/RELEASE index 6904651..2456a5c 100644 --- a/RELEASE +++ b/RELEASE @@ -10,6 +10,11 @@ The following functions are implemented. Errors are returned if an attempt is made to use some feature which is not implemented and printing the error stack will show `not implemented yet'. +Library + H5dont_atexit - don't call library close on exit + H5init - initialize library (happens automatically) + H5version - retrieve library version info + Templates H5Cclose - release template resources H5Ccopy - copy a template diff --git a/bin/checkposix b/bin/checkposix index aaf9169..229a106 100755 --- a/bin/checkposix +++ b/bin/checkposix @@ -42,11 +42,11 @@ while (<>) { # Ignore C statements that look sort of like function # calls. - next if $name =~ /^(if|for|return|sizeof|switch|while)$/; + next if $name =~ /^(if|for|return|sizeof|switch|while|void)$/; # These are really HDF5 functions/macros even though they don't # start with `h' or `H'. - next if $name =~ /^FUNC_(ENTER|LEAVE)$/; + next if $name =~ /^FUNC_(ENTER|LEAVE)(_INIT)?$/; next if $name =~ /^U?INT(8|16|32|64)(ENCODE|DECODE)$/; next if $name =~ /^(MIN|MAX3?|NELMTS|BOUND|CONSTR)$/; diff --git a/src/H5.c b/src/H5.c index abbc54d..30a33e0 100644 --- a/src/H5.c +++ b/src/H5.c @@ -142,7 +142,7 @@ H5_add_exit(void (*func) (void)) PURPOSE Terminate various static buffers and shutdown the library. USAGE - void HPend() + void H5_term_library() RETURNS SUCCEED/FAIL DESCRIPTION @@ -322,7 +322,7 @@ H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum) } /*------------------------------------------------------------------------- - * Function: H5init + * Function: H5open * * Purpose: Initialize the library. This is normally called * automatically, but if you find that an HDF5 library function @@ -341,9 +341,38 @@ H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum) *------------------------------------------------------------------------- */ herr_t -H5init(void) +H5open(void) { - FUNC_ENTER(H5init, FAIL); + FUNC_ENTER(H5open, FAIL); /* all work is done by FUNC_ENTER() */ FUNC_LEAVE(SUCCEED); } + + +/*------------------------------------------------------------------------- + * Function: H5close + * + * Purpose: Terminate the library and release all resources. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Friday, January 30, 1998 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5close (void) +{ + /* + * Don't call FUNC_ENTER() since we don't want to initialize the whole + * thing just to release it all right away. It is safe to call this + * function for an uninitialized library. + */ + H5_term_library (); + return SUCCEED; +} diff --git a/src/H5F.c b/src/H5F.c index a07e134..d6098fc 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -126,7 +126,8 @@ H5F_init_interface(void) FUNC_ENTER(H5F_init_interface, FAIL); /* Initialize the atom group for the file IDs */ - if ((ret_value = H5A_init_group(H5_FILE, H5A_FILEID_HASHSIZE, 0, NULL)) != FAIL) + if ((ret_value = H5A_init_group(H5_FILE, H5A_FILEID_HASHSIZE, 0, + (herr_t (*)(void*))H5Fclose)) != FAIL) ret_value = H5_add_exit(&H5F_term_interface); FUNC_LEAVE(ret_value); diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c index 09f61bc..f4e076d 100644 --- a/src/H5Fstdio.c +++ b/src/H5Fstdio.c @@ -16,7 +16,7 @@ #include #include -#define PABLO_MASK H5F_sec2 +#define PABLO_MASK H5F_stdio static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT NULL diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index a42ec8f..aa4c710 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -103,7 +103,7 @@ hbool_t H5P_is_simple (const H5P_t *sdim); uintn H5P_nelem (const H5P_t *space); const H5P_conv_t *H5P_find (const H5P_t *mem_space, const H5P_t *file_space); intn H5P_get_hyperslab (const H5P_t *ds, int offset[]/*out*/, - int size[]/*out*/, int stride[]/*out*/); + size_t size[]/*out*/, size_t stride[]/*out*/); /* Conversion functions for simple data spaces */ size_t H5P_simp_init (const struct H5O_layout_t *layout, diff --git a/src/H5Psimp.c b/src/H5Psimp.c index 60f9bd6..c0e0c36 100644 --- a/src/H5Psimp.c +++ b/src/H5Psimp.c @@ -93,6 +93,9 @@ H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout, size_t hsize[H5O_LAYOUT_NDIMS]; /*size of hyperslab */ size_t zero[H5O_LAYOUT_NDIMS]; /*zero */ size_t sample[H5O_LAYOUT_NDIMS]; /*hyperslab sampling */ +#ifndef LATER + intn file_offset_signed[H5O_LAYOUT_NDIMS]; +#endif intn space_ndims; /*dimensionality of space*/ intn i; /*counters */ @@ -120,10 +123,22 @@ H5P_simp_fgath (H5F_t *f, const struct H5O_layout_t *layout, * currently pass sample information into H5F_arr_read() much less * H5F_istore_read(). */ +#ifdef LATER if ((space_ndims=H5P_get_hyperslab (file_space, file_offset, hsize, sample))<0) { HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, "unable to retrieve hyperslab parameters"); +#else + if ((space_ndims=H5P_get_hyperslab (file_space, file_offset_signed, + hsize, sample))<0) { + HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, 0, + "unable to retrieve hyperslab parameters"); + } + for (i=0; i=0); + file_offset[i] = file_offset_signed[i]; + } +#endif for (i=0; i=0); + mem_offset[i] = mem_offset_signed[i]; + } +#endif for (i=0; i=0); + mem_offset[i] = mem_offset_signed[i]; + } +#endif for (i=0; i=0); + file_offset[i] = file_offset_signed[i]; + } +#endif for (i=0; i=0); - } /* Read the dataset */ s8 = calloc (h_size[0]*h_size[1], sizeof(s1_t)); diff --git a/test/dsets.c b/test/dsets.c index edb951d..58bfc4c 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -366,6 +366,9 @@ main(void) herr_t status; intn nerrors = 0; + status = H5open (); + assert (status>=0); + unlink("dataset.h5"); file = H5Fcreate("dataset.h5", H5ACC_DEFAULT, H5C_DEFAULT, H5C_DEFAULT); assert(file >= 0); @@ -391,5 +394,9 @@ main(void) exit(1); } printf("All dataset tests passed.\n"); + + status = H5close (); + assert (status>=0); + exit(0); } diff --git a/test/dtypes.c b/test/dtypes.c index 056734f..707fe29 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -215,8 +215,6 @@ main(void) herr_t status; intn nerrors = 0; - H5init(); - status = test_classes(); nerrors += status < 0 ? 1 : 0; -- cgit v0.12