[svn-r409] Changes since 19980604

----------------------

./html/Datatypes.html
	Updated documentation for named data types and type sharing.

./src/H5Farray.c
	Split a couple long lines.

./src/H5T.c
	The H5T_copy() demotes immutable types to read-only types so
	they're cleaned up properly and memory is not leaked.

./test/dtypes.c
	Modified to be more consistent with other tests.  Removed all
	internal header files, constants, types, and functions calls
	since the API is now complete enough to test
	everything. Temporary files are now removed.
This commit is contained in:
Robb Matzke 1998-06-04 22:35:31 -05:00
parent 15f2fb8184
commit a63ccc0c6b
4 changed files with 192 additions and 212 deletions

View File

@ -153,11 +153,12 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
&& f->shared->access_parms->u.mpio.access_mode==H5D_XFER_COLLECTIVE); && f->shared->access_parms->u.mpio.access_mode==H5D_XFER_COLLECTIVE);
if (is_collective){ if (is_collective){
#ifdef AKC #ifdef AKC
printf("%s: collective read requested\n", FUNC); printf("%s: collective read requested\n", FUNC);
#endif #endif
if (layout->type != H5D_CONTIGUOUS) if (layout->type != H5D_CONTIGUOUS)
HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL, HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL,
"collective access on non-contiguous datasets not supported yet"); "collective access on non-contiguous datasets not "
"supported yet");
} }
#endif #endif
@ -229,11 +230,12 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN, MPI_Allreduce(&temp, &min, 1, MPI_UNSIGNED_LONG, MPI_MIN,
f->shared->access_parms->u.mpio.comm); f->shared->access_parms->u.mpio.comm);
#ifdef AKC #ifdef AKC
printf("nelmts=%lu, min=%lu, max=%lu\n", temp, min, max); printf("nelmts=%lu, min=%lu, max=%lu\n", temp, min, max);
#endif #endif
if (max != min) if (max != min)
HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL,
"collective access with unequal number of blocks not supported yet"); "collective access with unequal number of "
"blocks not supported yet");
} }
#endif #endif

View File

@ -2874,10 +2874,12 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
case H5T_COPY_ALL: case H5T_COPY_ALL:
/* /*
* Return a transient type (locked or unlocked) or an unopened named * Return a transient type (locked or unlocked) or an unopened named
* type. * type. Immutable transient types are degraded to read-only.
*/ */
if (H5T_STATE_OPEN==new_dt->state) { if (H5T_STATE_OPEN==new_dt->state) {
new_dt->state = H5T_STATE_NAMED; new_dt->state = H5T_STATE_NAMED;
} else if (H5T_STATE_IMMUTABLE==new_dt->state) {
new_dt->state = H5T_STATE_RDONLY;
} }
break; break;

View File

@ -157,78 +157,6 @@ th5s.o: \
../src/H5Zpublic.h \ ../src/H5Zpublic.h \
../src/H5Pprivate.h \ ../src/H5Pprivate.h \
../src/H5Ppublic.h ../src/H5Ppublic.h
hyperslab.o: \
hyperslab.c \
../src/H5private.h \
../src/H5public.h \
../src/H5config.h
iopipe.o: \
iopipe.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
big.o: \
big.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h
chunk.o: \
chunk.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
dtypes.o: \ dtypes.o: \
dtypes.c \ dtypes.c \
../src/hdf5.h \ ../src/hdf5.h \
@ -250,12 +178,12 @@ dtypes.o: \
../src/H5Ppublic.h \ ../src/H5Ppublic.h \
../src/H5Zpublic.h \ ../src/H5Zpublic.h \
../src/H5Spublic.h \ ../src/H5Spublic.h \
../src/H5Tpublic.h \ ../src/H5Tpublic.h
../src/H5Iprivate.h \ hyperslab.o: \
hyperslab.c \
../src/H5private.h \ ../src/H5private.h \
../src/H5Tprivate.h \ ../src/H5public.h \
../src/H5Gprivate.h \ ../src/H5config.h
../src/H5Bprivate.h
istore.o: \ istore.o: \
istore.c \ istore.c \
../src/H5private.h \ ../src/H5private.h \
@ -368,6 +296,28 @@ external.o: \
../src/H5Zpublic.h \ ../src/H5Zpublic.h \
../src/H5Spublic.h \ ../src/H5Spublic.h \
../src/H5Tpublic.h ../src/H5Tpublic.h
iopipe.o: \
iopipe.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h
gheap.o: \ gheap.o: \
gheap.c \ gheap.c \
../src/H5private.h \ ../src/H5private.h \
@ -406,6 +356,29 @@ shtype.o: \
../src/H5Ppublic.h \ ../src/H5Ppublic.h \
../src/H5Zpublic.h \ ../src/H5Zpublic.h \
../src/H5Spublic.h ../src/H5Spublic.h
big.o: \
big.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h \
../src/H5private.h
links.o: \ links.o: \
links.c \ links.c \
../src/hdf5.h \ ../src/hdf5.h \
@ -425,3 +398,25 @@ links.o: \
../src/H5MMpublic.h \ ../src/H5MMpublic.h \
../src/H5Opublic.h \ ../src/H5Opublic.h \
../src/H5Ppublic.h ../src/H5Ppublic.h
chunk.o: \
chunk.c \
../src/hdf5.h \
../src/H5public.h \
../src/H5config.h \
../src/H5Ipublic.h \
../src/H5Apublic.h \
../src/H5ACpublic.h \
../src/H5Bpublic.h \
../src/H5Dpublic.h \
../src/H5Epublic.h \
../src/H5Fpublic.h \
../src/H5Gpublic.h \
../src/H5HGpublic.h \
../src/H5HLpublic.h \
../src/H5MFpublic.h \
../src/H5MMpublic.h \
../src/H5Opublic.h \
../src/H5Ppublic.h \
../src/H5Zpublic.h \
../src/H5Spublic.h \
../src/H5Tpublic.h

View File

@ -11,29 +11,70 @@
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
#include <H5Iprivate.h> #define FILE_NAME_1 "dtypes1.h5"
#include <H5Tprivate.h> #define FILE_NAME_2 "dtypes2.h5"
#ifndef HAVE_FUNCTION
#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
#define AT() printf (" at %s:%d in %s()...\n", \
__FILE__, __LINE__, __FUNCTION__);
typedef struct complex_t { typedef struct complex_t {
double re; double re;
double im; double im;
} complex_t; } complex_t;
/*-------------------------------------------------------------------------
* Function: clean
*
* Purpose: Removes test files
*
* Return: void
*
* Programmer: Robb Matzke
* Thursday, June 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
clean (void)
{
remove (FILE_NAME_1);
remove (FILE_NAME_2);
}
/*-------------------------------------------------------------------------
* Function: display_error_cb
*
* Purpose: Displays the error stack after printing "*FAILED*".
*
* Return: Success: 0
*
* Failure: -1
*
* Programmer: Robb Matzke
* Wednesday, March 4, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
display_error_cb (void *client_data)
{
puts ("*FAILED*");
H5Eprint (stdout);
return 0;
}
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: test_classes * Function: test_classes
* *
* Purpose: Test type classes * Purpose: Test type classes
* *
* Return: Success: SUCCEED * Return: Success: 0
* *
* Failure: FAIL * Failure: -1
* *
* Programmer: Robb Matzke * Programmer: Robb Matzke
* Tuesday, December 9, 1997 * Tuesday, December 9, 1997
@ -45,39 +86,38 @@ typedef struct complex_t {
static herr_t static herr_t
test_classes(void) test_classes(void)
{ {
H5T_class_t tcls;
printf("%-70s", "Testing H5Tget_class()"); printf("%-70s", "Testing H5Tget_class()");
if (H5T_INTEGER != H5Tget_class(H5T_NATIVE_INT)) { if ((tcls=H5Tget_class(H5T_NATIVE_INT))<0) goto error;
if (H5T_INTEGER!=tcls) {
puts("*FAILED*"); puts("*FAILED*");
if (!isatty(1)) { puts(" Invalid type class for H5T_NATIVE_INT");
AT();
printf(" Invalid type class for H5T_NATIVE_INT\n");
}
goto error; goto error;
} }
if (H5T_FLOAT != H5Tget_class(H5T_NATIVE_DOUBLE)) { if ((tcls=H5Tget_class(H5T_NATIVE_DOUBLE))<0) goto error;
if (H5T_FLOAT!=tcls) {
puts("*FAILED*"); puts("*FAILED*");
if (!isatty(1)) { puts(" Invalid type class for H5T_NATIVE_DOUBLE");
AT();
printf(" Invalid type class for H5T_NATIVE_DOUBLE\n");
}
goto error; goto error;
} }
puts(" PASSED"); puts(" PASSED");
return SUCCEED; return 0;
error: error:
return FAIL; return -1;
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: test_copy * Function: test_copy
* *
* Purpose: Are we able to copy a data type? * Purpose: Are we able to copy a data type?
* *
* Return: Success: SUCCEED * Return: Success: 0
* *
* Failure: FAIL * Failure: -1
* *
* Programmer: Robb Matzke * Programmer: Robb Matzke
* Tuesday, December 9, 1997 * Tuesday, December 9, 1997
@ -90,58 +130,37 @@ static herr_t
test_copy(void) test_copy(void)
{ {
hid_t a_copy; hid_t a_copy;
herr_t status;
herr_t (*func)(void*) = NULL;
void *client_data = NULL;
printf("%-70s", "Testing H5Tcopy()"); printf("%-70s", "Testing H5Tcopy()");
if ((a_copy = H5Tcopy(H5T_NATIVE_SHORT)) < 0) { if ((a_copy = H5Tcopy(H5T_NATIVE_SHORT)) < 0) goto error;
puts("*FAILED*"); if (H5Tclose(a_copy) < 0) goto error;
if (!isatty(1)) {
AT();
printf(" Cannot copy a builtin type.\n");
}
goto error;
}
if (H5Tclose(a_copy) < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
printf(" Cannot close the copied type.\n");
}
goto error;
}
/* Temporarily turn off error reporting. */ /* We should not be able to close a built-in byte */
H5Eget_auto (&func, &client_data); H5E_BEGIN_TRY {
H5Eset_auto (NULL, NULL); if (H5Tclose (H5T_NATIVE_CHAR)>=0) {
status = H5Tclose (H5T_NATIVE_CHAR); puts ("*FAILED*");
H5Eset_auto (func, client_data); puts (" Should not be able to close a predefined type!");
goto error;
}
} H5E_END_TRY;
if (status >= 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
printf(" Was able to free a built-in type.\n");
}
goto error;
}
puts(" PASSED"); puts(" PASSED");
return SUCCEED; return 0;
error: error:
return FAIL; return -1;
} }
/*------------------------------------------------------------------------- /*-------------------------------------------------------------------------
* Function: test_compound * Function: test_compound
* *
* Purpose: Tests various things about compound data types. * Purpose: Tests various things about compound data types.
* *
* Return: Success: SUCCEED * Return: Success: 0
* *
* Failure: FAIL * Failure: -1
* *
* Programmer: Robb Matzke * Programmer: Robb Matzke
* Wednesday, January 7, 1998 * Wednesday, January 7, 1998
@ -155,53 +174,24 @@ test_compound(void)
{ {
complex_t tmp; complex_t tmp;
hid_t complex_id; hid_t complex_id;
herr_t status;
printf("%-70s", "Testing compound data types"); printf("%-70s", "Testing compound data types");
/* Create the empty type */ /* Create the empty type */
complex_id = H5Tcreate(H5T_COMPOUND, sizeof tmp); if ((complex_id = H5Tcreate(H5T_COMPOUND, sizeof tmp))<0) goto error;
if (complex_id < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
printf(" Cannot create empty compound data type.\n");
}
goto error;
}
/* Add a couple fields */
status = H5Tinsert(complex_id, "real", HOFFSET(complex_t, re),
H5T_NATIVE_DOUBLE);
if (status < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
printf(" Cannot insert real component.\n");
}
goto error;
}
status = H5Tinsert(complex_id, "imaginary", HOFFSET(complex_t, im),
H5T_NATIVE_DOUBLE);
if (status < 0) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
printf(" Cannot insert imaginary component.\n");
}
goto error;
}
puts(" PASSED");
#if 0 /* Add a couple fields */
/* Just for debugging... */ if (H5Tinsert(complex_id, "real", HOFFSET(complex_t, re),
H5T_debug(H5I_object(complex_id), stdout); H5T_NATIVE_DOUBLE)<0) goto error;
printf("\n"); if (H5Tinsert(complex_id, "imaginary", HOFFSET(complex_t, im),
#endif H5T_NATIVE_DOUBLE)<0) goto error;
return SUCCEED; if (H5Tclose (complex_id)<0) goto error;
puts(" PASSED");
return 0;
error: error:
return FAIL; return -1;
} }
@ -210,9 +200,9 @@ test_compound(void)
* *
* Purpose: Tests transient data types. * Purpose: Tests transient data types.
* *
* Return: Success: SUCCEED * Return: Success: 0
* *
* Failure: FAIL * Failure: -1
* *
* Programmer: Robb Matzke * Programmer: Robb Matzke
* Thursday, June 4, 1998 * Thursday, June 4, 1998
@ -228,7 +218,7 @@ test_transient (void)
hid_t file, type, space, dset, t2; hid_t file, type, space, dset, t2;
printf ("%-70s", "Testing transient data types"); printf ("%-70s", "Testing transient data types");
if ((file=H5Fcreate ("dtypes1.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, if ((file=H5Fcreate (FILE_NAME_1, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, H5P_DEFAULT))<0) goto error; H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
space = H5Screate_simple (2, ds_size, ds_size); space = H5Screate_simple (2, ds_size, ds_size);
@ -298,7 +288,7 @@ test_transient (void)
H5Tclose (type); H5Tclose (type);
H5Sclose (space); H5Sclose (space);
puts (" PASSED"); puts (" PASSED");
return SUCCEED; return 0;
error: error:
H5E_BEGIN_TRY { H5E_BEGIN_TRY {
@ -308,7 +298,7 @@ test_transient (void)
H5Dclose (dset); H5Dclose (dset);
H5Fclose (file); H5Fclose (file);
} H5E_END_TRY; } H5E_END_TRY;
return FAIL; return -1;
} }
@ -317,9 +307,9 @@ test_transient (void)
* *
* Purpose: Tests named data types. * Purpose: Tests named data types.
* *
* Return: Success: SUCCEED * Return: Success: 0
* *
* Failure: FAIL * Failure: -1
* *
* Programmer: Robb Matzke * Programmer: Robb Matzke
* Monday, June 1, 1998 * Monday, June 1, 1998
@ -336,7 +326,7 @@ test_named (void)
static hsize_t ds_size[2] = {100, 200}; static hsize_t ds_size[2] = {100, 200};
printf ("%-70s", "Testing named data types"); printf ("%-70s", "Testing named data types");
if ((file=H5Fcreate ("dtypes2.h5", H5F_ACC_TRUNC|H5F_ACC_DEBUG, if ((file=H5Fcreate (FILE_NAME_2, H5F_ACC_TRUNC|H5F_ACC_DEBUG,
H5P_DEFAULT, H5P_DEFAULT))<0) goto error; H5P_DEFAULT, H5P_DEFAULT))<0) goto error;
space = H5Screate_simple (2, ds_size, ds_size); space = H5Screate_simple (2, ds_size, ds_size);
@ -468,7 +458,7 @@ test_named (void)
if (H5Sclose (space)<0) goto error; if (H5Sclose (space)<0) goto error;
if (H5Fclose (file)<0) goto error; if (H5Fclose (file)<0) goto error;
puts (" PASSED"); puts (" PASSED");
return SUCCEED; return 0;
error: error:
H5E_BEGIN_TRY { H5E_BEGIN_TRY {
@ -478,7 +468,7 @@ test_named (void)
H5Dclose (dset); H5Dclose (dset);
H5Fclose (file); H5Fclose (file);
} H5E_END_TRY; } H5E_END_TRY;
return FAIL; return -1;
} }
@ -501,33 +491,24 @@ test_named (void)
int int
main(void) main(void)
{ {
herr_t status; int nerrors = 0;
intn nerrors = 0;
status = test_classes(); /* Set the error handler */
nerrors += status < 0 ? 1 : 0; H5Eset_auto (display_error_cb, NULL);
status = test_copy(); /* Do the tests */
nerrors += status < 0 ? 1 : 0; nerrors += test_classes()<0 ? 1 : 0;
nerrors += test_copy()<0 ? 1 : 0;
status = test_compound(); nerrors += test_compound()<0 ? 1 : 0;
nerrors += status < 0 ? 1 : 0; nerrors += test_transient ()<0 ? 1 : 0;
nerrors += test_named ()<0 ? 1 : 0;
status = test_transient ();
nerrors += status < 0 ? 1 : 0;
status = test_named ();
nerrors += status < 0 ? 1 : 0;
if (nerrors) { if (nerrors) {
printf("***** %d DATA TYPE TEST%s FAILED! *****\n", printf("***** %d DATA TYPE TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S"); nerrors, 1 == nerrors ? "" : "S");
if (isatty(1)) {
printf("(Redirect output to a pager or a file to see debug "
"output)\n");
}
exit(1); exit(1);
} }
printf("All data type tests passed.\n"); printf("All data type tests passed.\n");
clean ();
return 0; return 0;
} }