summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Lu <songyulu@hdfgroup.org>2004-03-24 21:03:52 (GMT)
committerRaymond Lu <songyulu@hdfgroup.org>2004-03-24 21:03:52 (GMT)
commit370a4f930f5a4af3f5866b231b5b799db4506250 (patch)
tree222c3552e300668d5e7eb9a9a5d00b267776e96d
parent7d709797fc7625e646f05702ced307d2ca81a63f (diff)
downloadhdf5-370a4f930f5a4af3f5866b231b5b799db4506250.zip
hdf5-370a4f930f5a4af3f5866b231b5b799db4506250.tar.gz
hdf5-370a4f930f5a4af3f5866b231b5b799db4506250.tar.bz2
[svn-r8276] *** empty log message ***
-rw-r--r--src/H5D.c9
-rw-r--r--src/H5Dio.c14
-rw-r--r--src/H5S.c48
-rw-r--r--src/H5Sall.c3
-rw-r--r--src/H5Shyper.c4
-rw-r--r--src/H5Smpio.c1
-rw-r--r--src/H5Spoint.c4
-rw-r--r--src/H5Spublic.h3
-rw-r--r--src/H5Sselect.c7
9 files changed, 78 insertions, 15 deletions
diff --git a/src/H5D.c b/src/H5D.c
index da14a45..18f4c58 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1252,6 +1252,11 @@ H5D_get_space_status(const H5D_t *dset, H5D_space_status_t *allocation, hid_t dx
space=dset->space;
assert(space);
+ if(H5S_NULL == H5S_get_simple_extent_type(space)) {
+ *allocation = H5D_SPACE_STATUS_NOT_ALLOCATED;
+ HGOTO_DONE(SUCCEED)
+ }
+
/* Get the total number of elements in dataset's dataspace */
if((total_elem=H5S_get_simple_extent_npoints(space))<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get # of dataspace elements")
@@ -3206,7 +3211,9 @@ H5Diterate(void *buf, hid_t type_id, hid_t space_id, H5D_operator_t op,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid datatype")
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace")
-
+ if(H5S_NULL == H5S_get_simple_extent_type(space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "null dataspace isn't supported")
+
ret_value=H5S_select_iterate(buf,type_id,space,op,operator_data);
done:
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 13c3422..7be8294 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -176,7 +176,9 @@ H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype")
if (NULL == (buf_type=H5I_object_verify(buf_type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype")
-
+ if(H5S_NULL == H5S_get_simple_extent_type(space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "null dataspace isn't valid")
+
/* Fill the selection in the memory buffer */
if(H5D_fill(fill,fill_type,buf,buf_type,space, H5AC_dxpl_id)<0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed")
@@ -485,7 +487,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
if(H5S_select_valid(file_space)!=TRUE)
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent")
}
-
+
/* Get the default dataset transfer property list if the user didn't provide one */
if (H5P_DEFAULT == plist_id)
plist_id= H5P_DATASET_XFER_DEFAULT;
@@ -671,6 +673,9 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
file_space = dataset->space;
if (!mem_space)
mem_space = file_space;
+ if(H5S_NULL == H5S_get_simple_extent_type(mem_space) ||
+ H5S_NULL == H5S_get_simple_extent_type(file_space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "null dataspace isn't supported")
if((snelmts = H5S_get_select_npoints(mem_space))<0)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection")
H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t);
@@ -906,7 +911,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5S_t *mem_space,
if (!file_space)
file_space = dataset->space;
if (!mem_space)
- mem_space = file_space;
+ mem_space = file_space;
+ if(H5S_NULL == H5S_get_simple_extent_type(mem_space) ||
+ H5S_NULL == H5S_get_simple_extent_type(file_space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "null dataspace isn't supported")
if((snelmts = H5S_get_select_npoints(mem_space))<0)
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "src dataspace has invalid selection")
H5_ASSIGN_OVERFLOW(nelmts,snelmts,hssize_t,hsize_t);
diff --git a/src/H5S.c b/src/H5S.c
index f599213..73c5fb0 100644
--- a/src/H5S.c
+++ b/src/H5S.c
@@ -307,17 +307,23 @@ H5S_create(H5S_class_t type)
switch(type) {
case H5S_SCALAR:
ret_value->extent.nelem = 1;
+ if(H5S_select_all(ret_value,0)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
break;
case H5S_SIMPLE:
ret_value->extent.nelem = 0;
+ if(H5S_select_all(ret_value,0)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
+ break;
+ case H5S_NULL:
+ ret_value->extent.nelem = 0;
+ if(H5S_select_none(ret_value)<0)
+ HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set selection to none");
break;
default:
assert("unknown dataspace (extent) type" && 0);
break;
} /* end switch */
-
- if(H5S_select_all(ret_value,0)<0)
- HGOTO_ERROR (H5E_DATASPACE, H5E_CANTSET, NULL, "unable to set all selection");
} /* end if */
done:
@@ -353,7 +359,7 @@ H5Screate(H5S_class_t type)
H5TRACE1("i","Sc",type);
/* Check args */
- if(type<=H5S_NO_CLASS || type> H5S_SIMPLE) /* don't allow complex dataspace yet */
+ if(type<=H5S_NO_CLASS || type> H5S_NULL) /* don't allow complex dataspace yet */
HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace type");
if (NULL==(new_ds=H5S_create(type)))
@@ -402,6 +408,7 @@ H5S_extent_release(H5S_t *ds)
/*nothing needed */
break;
+ case H5S_NULL:
case H5S_SCALAR:
/*nothing needed */
break;
@@ -648,6 +655,7 @@ H5S_extent_copy(H5S_extent_t *dst, const H5S_extent_t *src)
*dst=*src;
switch (src->type) {
+ case H5S_NULL:
case H5S_SCALAR:
/*nothing needed */
break;
@@ -831,10 +839,14 @@ H5S_get_npoints_max(const H5S_t *ds)
assert(ds);
switch (ds->extent.type) {
+ case H5S_NULL:
+ ret_value = 0;
+ break;
+
case H5S_SCALAR:
ret_value = 1;
break;
-
+
case H5S_SIMPLE:
if (ds->extent.u.simple.max) {
for (ret_value=1, u=0; u<ds->extent.u.simple.rank; u++) {
@@ -929,6 +941,7 @@ H5S_get_simple_extent_ndims(const H5S_t *ds)
assert(ds);
switch (ds->extent.type) {
+ case H5S_NULL:
case H5S_SCALAR:
ret_value = 0;
break;
@@ -1022,6 +1035,7 @@ H5S_get_simple_extent_dims(const H5S_t *ds, hsize_t dims[], hsize_t max_dims[])
assert(ds);
switch (ds->extent.type) {
+ case H5S_NULL:
case H5S_SCALAR:
ret_value = 0;
break;
@@ -1079,6 +1093,7 @@ H5S_modify(H5G_entry_t *ent, const H5S_t *ds, hbool_t update_time, hid_t dxpl_id
assert(ds);
switch (ds->extent.type) {
+ case H5S_NULL:
case H5S_SCALAR:
case H5S_SIMPLE:
if (H5O_modify(ent, H5O_SDSPACE_ID, 0, 0, update_time, &(ds->extent.u.simple), dxpl_id)<0)
@@ -1125,6 +1140,7 @@ H5S_append(H5F_t *f, hid_t dxpl_id, struct H5O_t *oh, const H5S_t *ds)
assert(ds);
switch (ds->extent.type) {
+ case H5S_NULL:
case H5S_SCALAR:
case H5S_SIMPLE:
if (H5O_append(f, dxpl_id, oh, H5O_SDSPACE_ID, 0, &(ds->extent.u.simple))<0)
@@ -1190,7 +1206,8 @@ H5S_read(H5G_entry_t *ent, hid_t dxpl_id)
nelem*=ds->extent.u.simple.size[u];
ds->extent.nelem = nelem;
} /* end if */
- else {
+/* How to distinguish between H5S_SCALAR and H5S_NULL? */
+ else {
ds->extent.type = H5S_SCALAR;
ds->extent.nelem = 1;
} /* end else */
@@ -1243,6 +1260,7 @@ H5S_is_simple(const H5S_t *sdim)
/* Check args and all the boring stuff. */
assert(sdim);
+ /* H5S_NULL shouldn't be simple dataspace */
ret_value = (sdim->extent.type == H5S_SIMPLE ||
sdim->extent.type == H5S_SCALAR) ? TRUE : FALSE;
@@ -1309,6 +1327,10 @@ H5Sis_simple(hid_t space_id)
dimensions in the DIMS array are used as the maximum dimensions.
Currently, only the first dimension in the array (the slowest) may be
unlimited in size.
+
+ MODIFICATION
+ A null dataspace cannot be converted from simple space in this function.
+
--------------------------------------------------------------------------*/
herr_t
H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
@@ -1324,6 +1346,8 @@ H5Sset_extent_simple(hid_t space_id, int rank, const hsize_t dims[/*rank*/],
/* Check args */
if ((space = H5I_object_verify(space_id,H5I_DATASPACE)) == NULL)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
+ if(space->extent.type == H5S_NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid dataspace");
if (rank > 0 && dims == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no dimensions specified");
if (rank<0 || rank>H5S_MAX_RANK)
@@ -1378,7 +1402,7 @@ H5S_set_extent_simple (H5S_t *space, unsigned rank, const hsize_t *dims,
/* Check args */
assert(rank<=H5S_MAX_RANK);
assert(0==rank || dims);
-
+
/* If there was a previous offset for the selection, release it */
if(space->select.offset!=NULL)
space->select.offset=H5FL_ARR_FREE(hssize_t,space->select.offset);
@@ -1925,8 +1949,9 @@ H5Soffset_simple(hid_t space_id, const hssize_t *offset)
/* Check args */
if (NULL == (space = H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
- if (space->extent.u.simple.rank==0 || space->extent.type==H5S_SCALAR)
- HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar dataspace");
+ if (space->extent.u.simple.rank==0 || space->extent.type==H5S_SCALAR
+ || space->extent.type==H5S_NULL)
+ HGOTO_ERROR(H5E_ATOM, H5E_UNSUPPORTED, FAIL, "can't set offset on scalar or null dataspace");
if (offset == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no offset specified");
@@ -2047,6 +2072,11 @@ H5S_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE *stream, int indent,
FUNC_ENTER_NOAPI(H5S_debug, FAIL);
switch (mesg->extent.type) {
+ case H5S_NULL:
+ fprintf(stream, "%*s%-*s H5S_NULL\n", indent, "", fwidth,
+ "Space class:");
+ break;
+
case H5S_SCALAR:
fprintf(stream, "%*s%-*s H5S_SCALAR\n", indent, "", fwidth,
"Space class:");
diff --git a/src/H5Sall.c b/src/H5Sall.c
index 4dfcc70..f03dbcd 100644
--- a/src/H5Sall.c
+++ b/src/H5Sall.c
@@ -763,6 +763,9 @@ herr_t H5Sselect_all (hid_t spaceid)
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ if (space->extent.type == H5S_NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid data space");
+
/* Call internal routine to do the work */
if((ret_value=H5S_select_all(space,1))<0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDELETE, FAIL, "can't change selection");
diff --git a/src/H5Shyper.c b/src/H5Shyper.c
index 3e2e5d4..b6b3d2f 100644
--- a/src/H5Shyper.c
+++ b/src/H5Shyper.c
@@ -5816,6 +5816,8 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if (H5S_SCALAR==H5S_get_simple_extent_type(space))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space");
+ if (H5S_NULL==H5S_get_simple_extent_type(space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space");
if(start==NULL || count==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
@@ -6409,6 +6411,8 @@ H5Sselect_hyperslab(hid_t space_id, H5S_seloper_t op, const hssize_t start[],
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if (H5S_SCALAR==H5S_get_simple_extent_type(space))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space");
+ if (H5S_NULL==H5S_get_simple_extent_type(space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space");
if(start==NULL || count==NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "hyperslab not specified");
if(!(op>H5S_SELECT_NOOP && op<H5S_SELECT_INVALID))
diff --git a/src/H5Smpio.c b/src/H5Smpio.c
index 2312347..9b5a2fa 100644
--- a/src/H5Smpio.c
+++ b/src/H5Smpio.c
@@ -531,6 +531,7 @@ H5S_mpio_space_type( const H5S_t *space, size_t elmt_size,
/* Creat MPI type based on the kind of selection */
switch (space->extent.type) {
+ case H5S_NULL:
case H5S_SCALAR:
case H5S_SIMPLE:
switch(space->select.type) {
diff --git a/src/H5Spoint.c b/src/H5Spoint.c
index 9b469c5..0200a7c 100644
--- a/src/H5Spoint.c
+++ b/src/H5Spoint.c
@@ -1285,7 +1285,9 @@ H5Sselect_elements(hid_t spaceid, H5S_seloper_t op, size_t num_elem,
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
if (H5S_SCALAR==H5S_get_simple_extent_type(space))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_SCALAR space");
- if(coord==NULL || num_elem==0)
+ if (H5S_NULL==H5S_get_simple_extent_type(space))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hyperslab doesn't support H5S_NULL space");
+ if(coord==NULL || num_elem==0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "elements not specified");
if(!(op==H5S_SELECT_SET || op==H5S_SELECT_APPEND || op==H5S_SELECT_PREPEND))
HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "operations other than H5S_SELECT_SET not supported currently");
diff --git a/src/H5Spublic.h b/src/H5Spublic.h
index 76de620..1121c02 100644
--- a/src/H5Spublic.h
+++ b/src/H5Spublic.h
@@ -34,7 +34,8 @@ typedef enum H5S_class_t {
H5S_NO_CLASS = -1, /*error */
H5S_SCALAR = 0, /*scalar variable */
H5S_SIMPLE = 1, /*simple data space */
- H5S_COMPLEX = 2 /*complex data space */
+ H5S_NULL = 2, /*null data space */
+ H5S_COMPLEX = 3 /*complex data space */
} H5S_class_t;
/* Different ways of combining selections */
diff --git a/src/H5Sselect.c b/src/H5Sselect.c
index a52bb12..1150e5b 100644
--- a/src/H5Sselect.c
+++ b/src/H5Sselect.c
@@ -146,6 +146,7 @@ H5S_select_copy (H5S_t *dst, const H5S_t *src)
/* Perform correct type of copy based on the type of selection */
switch (src->extent.type) {
+ case H5S_NULL:
case H5S_SCALAR:
/*nothing needed */
break;
@@ -251,6 +252,9 @@ H5Sget_select_npoints(hid_t spaceid)
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace");
+ if (space->extent.type == H5S_NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace");
+
ret_value = H5S_get_select_npoints(space);
done:
@@ -325,6 +329,9 @@ H5Sselect_valid(hid_t spaceid)
if (NULL == (space=H5I_object_verify(spaceid, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace");
+ if (space->extent.type == H5S_NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid dataspace");
+
ret_value = H5S_select_valid(space);
done: