summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1997-08-29 19:26:32 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1997-08-29 19:26:32 (GMT)
commit39a94b2f538e6b4d1b13362e022141ba8cb599c0 (patch)
tree93c81660e0b8e423868bed0ca907bfe046b4c878
parentc48f8b7590ed6bc334a6d62ab651cda8124ba90f (diff)
downloadhdf5-39a94b2f538e6b4d1b13362e022141ba8cb599c0.zip
hdf5-39a94b2f538e6b4d1b13362e022141ba8cb599c0.tar.gz
hdf5-39a94b2f538e6b4d1b13362e022141ba8cb599c0.tar.bz2
[svn-r53] Added datatype and dimensionality messages to dataset header, cleaned up more
code, etc.
-rw-r--r--src/H5D.c76
-rw-r--r--src/H5Dprivate.h8
-rw-r--r--src/H5Oprivate.h12
-rw-r--r--src/H5Osdtyp.c28
-rw-r--r--src/H5P.c82
-rw-r--r--src/H5Pprivate.h10
-rw-r--r--src/H5T.c46
-rw-r--r--src/H5Tprivate.h1
-rw-r--r--src/Makefile77
9 files changed, 286 insertions, 54 deletions
diff --git a/src/H5D.c b/src/H5D.c
index a87fe24..95990b8 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -108,7 +108,6 @@ hatom_t H5D_create(hatom_t owner_id, hobjtype_t type, const char *name)
new_dset->file=owner_id;
else
new_dset->file=H5Mget_file(owner_id);
- new_dset->parent=owner_id; /* set the owner's ID */
new_dset->name=HDstrdup(name); /* make a copy of the dataset name */
new_dset->modified=BTRUE; /* Yep, we're new... */
new_dset->type=0;
@@ -167,8 +166,8 @@ herr_t H5Dset_info(hatom_t oid, hatom_t tid, hatom_t did)
if(dataset->type!=0 || dataset->dim!=0)
HGOTO_ERROR(H5E_FUNC, H5E_ALREADYINIT, FAIL);
- dataset->type=tid;
- dataset->dim=did;
+ dataset->type=H5Aatom_object(tid);
+ dataset->dim=H5Aatom_object(did);
dataset->modified=BTRUE; /* indicate the values have changed */
done:
@@ -277,36 +276,57 @@ herr_t H5D_flush(hatom_t oid)
/* Check if we have information to flush to the file... */
if (dataset->modified) {
- /* Get the dataset's file... (I'm not fond of this. -QAK) */
- if((file=H5Aatom_object(dataset->file))==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_BADATOM, FAIL);
+ /* Get the dataset's file... (I'm not fond of this. -QAK) */
+ if((file=H5Aatom_object(dataset->file))==NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_BADATOM, FAIL);
+
+
+ if (dataset->header<=0) {
+ /*
+ * Create the object header.
+ */
+ if ((dataset->header = H5O_new (file, 0, H5D_MINHDR_SIZE))<0) {
+ HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't create header*/
+ }
+
+ /*
+ * Start creating the symbol table entry. Inserting messages
+ * into the header may cache things in this entry.
+ */
+ d_sym.header = dataset->header;
+ d_sym.type = H5G_NOTHING_CACHED;
+
+ /*
+ * Write the necessary messages to the header.
+ */
+ /* Check if this dataset has an "atomic" datatype */
+ if(BTRUE==H5T_is_atomic(dataset->type))
+ {
+ if(H5O_modify(file,dataset->header,&d_sym,NULL,H5O_SIM_DTYPE,H5O_NEW_MESG,dataset->type)==FAIL)
+ HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
+ } /* end if */
+ else
+ { /* if it's not an atomic datatype, fail for right now */
+ HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ } /* end else */
+ /* Check if this dataset has "simple" dimensionality */
+ if(BTRUE==H5P_is_simple(dataset->dim))
+ {
+ if(H5O_modify(file,dataset->header,&d_sym,NULL,H5O_SIM_DIM,H5O_NEW_MESG,dataset->dim)==FAIL)
+ HGOTO_ERROR (H5E_INTERNAL, H5E_CANTCREATE, FAIL);
+ } /* end if */
+ else
+ { /* if it's not an atomic datatype, fail for right now */
+ HGOTO_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL);
+ } /* end else */
- if (dataset->header<=0) {
/*
- * Create the object header.
- */
- if ((dataset->header = H5O_new (file, 0, H5D_MINHDR_SIZE))<0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); /*can't create header*/
- }
-
- /*
- * Start creating the symbol table entry. Inserting messages
- * into the header may cache things in this entry.
+ * Give the object header a name so others can access it.
*/
- d_sym.header = dataset->header;
+#if 1 /* SEE_BELOW */
d_sym.type = H5G_NOTHING_CACHED;
-
- /*
- * Write the necessary messages to the header.
- */
-/*-------------------------------------------------------------------------
- * Quincey? It should be just a matter of filling in the
- * appropriate H5O_*_t struct and passing it to
- * H5O_modify() along with &d_sym.
- *-------------------------------------------------------------------------
- */
-
+#endif
/*
* Give the object header a name so others can access it.
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 43558e8..907395d 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -23,15 +23,15 @@
/* Private headers needed by this file */
#include <H5private.h>
#include <H5Cprivate.h> /* for the hobjtype_t type */
-
+#include <H5Tprivate.h> /* for the h5_datatype_t type */
+#include <H5Pprivate.h> /* for the H5P_sdim_t type */
typedef struct {
hatom_t file; /* ID of the file-store of this object */
- hatom_t parent; /* ID of the parent of this object (objects in the root-directory should have the file ID here, otherwise the directory ID is here) */
char *name; /* Name of dataset */
hbool_t modified; /* Whether the dataset has been modified from version on disk */
- hatom_t type; /* ID of Datatype of the dataset */
- hatom_t dim; /* ID of Dimensionality of the dataset */
+ h5_datatype_t *type; /* Pointer to datatype of the dataset */
+ H5P_sdim_t *dim; /* Pointer to dimensionality of the dataset */
haddr_t header; /* offset of the object header for this dataset */
haddr_t data; /* offset of the data in the file */
} H5D_dataset_t;
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index 43aace9..f097195 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -22,6 +22,8 @@
#include <H5private.h>
#include <H5Fprivate.h>
#include <H5Gprivate.h>
+#include <H5Tprivate.h>
+#include <H5Pprivate.h>
#define H5O_MIN_SIZE 16 /*min obj header data size */
#define H5O_NMESGS 32 /*initial number of messages */
@@ -96,6 +98,8 @@ extern const H5O_class_t H5O_NULL[1];
#define H5O_SIM_DIM_ID 0x0001
extern const H5O_class_t H5O_SIM_DIM[1];
+/* Hmm, let's try this... */
+#ifdef QAK
typedef struct {
uint32 rank; /* Number of dimensions */
uint32 dim_flags; /* Dimension flags */
@@ -103,6 +107,9 @@ typedef struct {
uint32 *max; /* Maximum dimension sizes */
uint32 *perm; /* Dimension permutations */
} H5O_sim_dim_t;
+#else /* QAK */
+typedef H5P_sdim_t H5O_sim_dim_t;
+#endif /* QAK */
/*
* Simple Datatype message.
@@ -110,11 +117,16 @@ typedef struct {
#define H5O_SIM_DTYPE_ID 0x0003
extern const H5O_class_t H5O_SIM_DTYPE[1];
+/* Hmm, let's try this... */
+#ifdef QAK
typedef struct {
uint8 length; /* Number of bytes */
uint8 arch; /* Architecture format of the data */
hatom_t type; /* Type of the data */
} H5O_sim_dtype_t;
+#else /* QAK */
+typedef h5_atomic_type_t H5O_sim_dtype_t;
+#endif /* QAK */
/*
* Object name message.
diff --git a/src/H5Osdtyp.c b/src/H5Osdtyp.c
index 79e3db2..962b646 100644
--- a/src/H5Osdtyp.c
+++ b/src/H5Osdtyp.c
@@ -99,9 +99,9 @@ H5O_sim_dtype_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p)
/* decode */
if((sdtype = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t)))!=NULL)
{
- sdtype->length=*p++;
+ sdtype->len=*p++;
sdtype->arch=*p++;
- UINT16DECODE(p,sdtype->type);
+ UINT16DECODE(p,sdtype->base);
} /* end if */
FUNC_LEAVE (sdtype);
@@ -138,9 +138,9 @@ H5O_sim_dtype_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, const void *mes
assert (sdtype);
/* encode */
- *p++=sdtype->length;
+ *p++=sdtype->len;
*p++=sdtype->arch;
- UINT16ENCODE(p,sdtype->type);
+ UINT16ENCODE(p,sdtype->base);
FUNC_LEAVE (SUCCEED);
} /* end H5O_sim_dtype_encode() */
@@ -180,9 +180,9 @@ H5O_sim_dtype_fast (const H5G_entry_t *ent, void *mesg)
if((sdtype = H5MM_xcalloc (1, sizeof(H5O_sim_dtype_t)))!=NULL)
{
p=(const uint8 *)&ent->cache.sdata.nt;
- sdtype->length=*p++;
+ sdtype->len=*p++;
sdtype->arch=*p++;
- UINT16DECODE(p,sdtype->type);
+ UINT16DECODE(p,sdtype->base);
} /* end if */
} /* end if */
else
@@ -232,16 +232,16 @@ H5O_sim_dtype_cache (H5G_entry_t *ent, const void *mesg)
{
modified = BTRUE;
ent->type = H5G_CACHED_SDATA;
- *p++=sdtype->length;
+ *p++=sdtype->len;
*p++=sdtype->arch;
- UINT16ENCODE(p,sdtype->type);
+ UINT16ENCODE(p,sdtype->base);
} /* end if */
else
{
- if(ent->cache.sdata.nt.length != sdtype->length)
+ if(ent->cache.sdata.nt.length != sdtype->len)
{
modified = BTRUE;
- ent->cache.sdata.nt.length = sdtype->length;
+ ent->cache.sdata.nt.length = sdtype->len;
} /* end if */
if (ent->cache.sdata.nt.arch != sdtype->arch)
@@ -250,10 +250,10 @@ H5O_sim_dtype_cache (H5G_entry_t *ent, const void *mesg)
ent->cache.sdata.nt.arch = sdtype->arch;
} /* end if */
- if (ent->cache.sdata.nt.type != sdtype->type)
+ if (ent->cache.sdata.nt.type != (uint16)sdtype->base)
{
modified = BTRUE;
- ent->cache.sdata.nt.type = sdtype->type;
+ ent->cache.sdata.nt.type = (uint16)sdtype->base;
} /* end if */
} /* end else */
@@ -351,13 +351,13 @@ H5O_sim_dtype_debug (hdf5_file_t *f, const void *mesg, FILE *stream,
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Length:",
- (unsigned long)(sdtype->length));
+ (unsigned long)(sdtype->len));
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Architecture:",
(unsigned long)(sdtype->arch));
fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
"Data-Type:",
- (unsigned long)(sdtype->type));
+ (unsigned long)((uint16)sdtype->base));
FUNC_LEAVE (SUCCEED);
} /* end H5O_sim_dtype_debug() */
diff --git a/src/H5P.c b/src/H5P.c
index abaa5c1..3c51ed0 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -117,6 +117,86 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5P_get_lrank
+ PURPOSE
+ Return the logical rank of a dataspace (internal)
+ USAGE
+ uint32 H5P_get_lrank(sdim)
+ H5P_sdim_t *sdim; IN: Pointer to dataspace object to query
+ RETURNS
+ The logical rank of a dataspace on success, UFAIL on failure
+ DESCRIPTION
+ This function determines the number of logical dimensions in a
+ dataspace. The logical rank is the actual number of dimensions of the
+ dataspace, not the dimensionality of the space its embedded in.
+ UFAIL is returned on an error, otherwise the rank is returned.
+--------------------------------------------------------------------------*/
+uint32 H5P_get_lrank(H5P_sdim_t *sdim)
+{
+ uint32 ret_value = UFAIL;
+
+ FUNC_ENTER(H5P_get_lrank, H5P_init_interface, UFAIL);
+
+ /* Clear errors and check args and all the boring stuff. */
+ H5ECLEAR;
+
+ assert(sdim);
+ ret_value=sdim->rank;
+
+#ifdef LATER
+done:
+#endif /* LATER */
+ if(ret_value == UFAIL)
+ { /* Error condition cleanup */
+
+ } /* end if */
+
+ /* Normal function cleanup */
+
+ FUNC_LEAVE(ret_value);
+} /* end H5P_get_lrank() */
+
+/*--------------------------------------------------------------------------
+ NAME
+ H5P_is_simple
+ PURPOSE
+ Check if a dataspace is simple (internal)
+ USAGE
+ hbool_t H5P_is_simple(sdim)
+ H5P_sdim_t *sdim; IN: Pointer to dataspace object to query
+ RETURNS
+ BTRUE/BFALSE/BFAIL
+ DESCRIPTION
+ This function determines the if a dataspace is "simple". ie. if it
+ has orthogonal, evenly spaced dimensions.
+--------------------------------------------------------------------------*/
+hbool_t H5P_is_simple(H5P_sdim_t *sdim)
+{
+ hbool_t ret_value = BFAIL;
+
+ FUNC_ENTER(H5P_get_lrank, H5P_init_interface, UFAIL);
+
+ /* Clear errors and check args and all the boring stuff. */
+ H5ECLEAR;
+
+ assert(sdim);
+ ret_value=BTRUE; /* Currently all dataspaces are simple */
+
+#ifdef LATER
+done:
+#endif /* LATER */
+ if(ret_value == BFAIL)
+ { /* Error condition cleanup */
+
+ } /* end if */
+
+ /* Normal function cleanup */
+
+ FUNC_LEAVE(ret_value);
+} /* end H5P_is_simple() */
+
+/*--------------------------------------------------------------------------
+ NAME
H5Pnelem
PURPOSE
Return the number of elements in a dataspace
@@ -146,7 +226,9 @@ uintn H5Pnelem(hatom_t sid)
ret_value=1;
#endif /* FINISH_THIS */
+#ifdef LATER
done:
+#endif /* LATER */
if(ret_value == UFAIL)
{ /* Error condition cleanup */
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 455ad4b..062b2da 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -24,10 +24,20 @@
#include <H5private.h>
#include <H5Cprivate.h> /*for hobjtype_t defn*/
+typedef struct {
+ uint32 rank; /* Number of dimensions */
+ uint32 dim_flags; /* Dimension flags */
+ uint32 *size; /* Dimension sizes */
+ uint32 *max; /* Maximum dimension sizes */
+ uint32 *perm; /* Dimension permutations */
+} H5P_sdim_t;
+
#define H5P_RESERVED_ATOMS 1
/* Private functions */
hatom_t H5P_create(hatom_t owner_id, hobjtype_t type, const char *name);
+uint32 H5P_get_lrank(H5P_sdim_t *sdim);
+hbool_t H5P_is_simple(H5P_sdim_t *sdim);
herr_t H5P_release(hatom_t oid);
#endif
diff --git a/src/H5T.c b/src/H5T.c
index 1411247..da6de94 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -25,7 +25,7 @@ static char RcsId[] = "@(#)$Revision$";
EXPORTED ROUTINES
H5Tget_num_fields -- Get the number of fields in a compound datatype
H5Tis_field_atomic -- Check if a field is atomic
- H5Tis_atomic -- Check if a datatype is atomic
+ H5Tis_atomic/H5T_is_atomic -- Check if a datatype is atomic
H5Tset_type -- Set the base type of a user-defined datatype
H5Tadd_field -- Add a field to a compound datatype
H5Tsize -- Determine the size of a datatype
@@ -237,9 +237,48 @@ done:
/*--------------------------------------------------------------------------
NAME
+ H5T_is_atomic
+ PURPOSE
+ Check if a datatype is atomic (internal)
+ USAGE
+ hbool_t H5Tis_atomic(type)
+ h5_datatype_t *type; IN: Ptr to datatype object to query
+ RETURNS
+ BFAIL/BTRUE/BFALSE
+ DESCRIPTION
+ This function checks the basic type of a user-defined datatype. BTRUE
+ is returned if the datatype is atomic (i.e. not compound), BFALSE is
+ returned if the datatype is compound, BFAIL on error.
+--------------------------------------------------------------------------*/
+hbool_t H5T_is_atomic(h5_datatype_t *type)
+{
+ hbool_t ret_value = BTRUE;
+
+ FUNC_ENTER(H5T_is_atomic, H5T_init_interface, BFAIL);
+
+ /* Clear errors and check args and all the boring stuff. */
+ H5ECLEAR;
+
+ /* Check the base type of the datatype */
+ if(H5T_COMPOUND==type->dt.base)
+ ret_value=BFALSE;
+
+done:
+ if(ret_value == BFAIL)
+ { /* Error condition cleanup */
+
+ } /* end if */
+
+ /* Normal function cleanup */
+
+ FUNC_LEAVE(ret_value);
+} /* end H5T_is_atomic() */
+
+/*--------------------------------------------------------------------------
+ NAME
H5Tis_atomic
PURPOSE
- Check if a datatype is atomic
+ Check if a datatype is atomic (API)
USAGE
hbool_t H5Tis_atomic(tid)
hatom_t tid; IN: Datatype object to query
@@ -265,8 +304,7 @@ hbool_t H5Tis_atomic(hatom_t tid)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);
/* Check the base type of the datatype */
- if(H5T_COMPOUND==dt->dt.base)
- ret_value=BFALSE;
+ ret_value=H5T_is_atomic(dt);
done:
if(ret_value == BFAIL)
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index c3999a0..c780b0b 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -52,6 +52,7 @@ typedef struct {
/* Private functions */
hatom_t H5T_create(hatom_t owner_id, hobjtype_t type, const char *name);
+hbool_t H5T_is_atomic(h5_datatype_t *type);
herr_t H5T_release(hatom_t oid);
#endif
diff --git a/src/Makefile b/src/Makefile
index 7286596..1c8dff7 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -31,12 +31,73 @@ INSTALL_PROGRAM=${INSTALL}
INSTALL_DATA=${INSTALL} -m 644
# Installation points
+ROOT=/usr/home/koziol/hdf_dev/hdf5
prefix=/usr/local
exec_prefix=${prefix}
bindir=${exec_prefix}/bin
libdir=${exec_prefix}/lib
includedir=${prefix}/include
+# The default is to build the library and programs.
+all: lib progs
+
+# The following rules insure that the Makefile is up-to-date by rerunning
+# various autoconf components (although not all versions of make assume
+# that the makefile is implicitly a target). We use time stamp files to
+# keep track of the most recent update of H5config.h.in and H5config.h
+# because autoheader and config.status don't update the modification time
+# if the contents don't change.
+#
+# Graphically, the dependencies are:
+#
+# configure.in
+# | |
+# +--------------------+ +-------------------+
+# | |
+# stamp1 configure
+# | |
+# | config.status
+# | | |
+# | +-------------------------------------+ |
+# | | |
+# stamp2 Makefile.in |
+# | | |
+# | +-----------+ +------+
+# +-----------------------------+ | |
+# | | |
+# Makefile
+#
+# A side effect of updating stamp1 is to generate H5config.h.in and a
+# side effect of updating stamp2 is to generate H5config.h. When using
+# a version of make that doesn't treat the makefile as the initial target
+# the user may want to occassionally type `make Makefile' in any source
+# directory.
+#
+STAMP1=$(ROOT)/config/stamp1
+STAMP2=$(ROOT)/config/stamp2
+
+MAKEFILE_PARTS=$(ROOT)/config/commence.in Makefile.in \
+ $(ROOT)/config/conclude.in $(ROOT)/config/depend.in
+
+$(STAMP1): $(ROOT)/configure.in
+ -(cd $(ROOT); \
+ touch $(STAMP1); \
+ autoheader)
+
+$(STAMP2): $(STAMP1) $(ROOT)/config.status
+ -(cd $(ROOT); \
+ touch $(STAMP2); \
+ CONFIG_FILES= CONFIG_HEADERS=src/H5config.h ./config.status)
+
+$(ROOT)/configure: $(ROOT)/configure.in
+ -(cd $(ROOT); autoconf)
+
+$(ROOT)/config.status: $(ROOT)/configure
+ -(cd $(ROOT); ./config.status --recheck)
+
+Makefile: $(MAKEFILE_PARTS) $(ROOT)/config.status $(STAMP2)
+ -(cd $(ROOT); CONFIG_HEADERS= ./config.status)
+
#------------------------------------------------------------------------------
# The following section of this makefile comes from the middle of `Makefile.in'
# from this directory. It was generated by running `config.status'.
@@ -82,22 +143,30 @@ debug: debug.o $(LIB)
# from `./config/conclude.in'.
#------------------------------------------------------------------------------
-# The default is to build the library and programs.
-all: $(LIB) $(PROGS)
-lib: $(LIB)
-
# This is the target for the library described in the main body of the
# makefile.
#
+lib: $(LIB)
$(LIB) __no_library__: $(LIB_OBJ)
$(AR) -rc $@ $(LIB_OBJ)
$(RANLIB) $@
+progs: $(PROGS)
+
# Build a tags file in this directory.
TAGS: $(LIB_SRC)
$(RM) $@
-etags $(LIB_SRC)
+# Runs each test in order, passing $(TEST_FLAGS) to the program.
+test: $(PROGS)
+ @for test in $(TESTS) dummy; do \
+ if test $$test != dummy; then \
+ echo "$$test $(TEST_FLAGS)"; \
+ $$test $(TEST_FLAGS) || exit 1; \
+ fi; \
+ done;
+
# Install the library, the public header files, and programs.
install: $(LIB) $(PUB_HDR) $(PROGS)
@if test -n "$(LIB)"; then \