summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--hl/src/H5DS.c337
-rw-r--r--hl/test/test_ds.c272
2 files changed, 337 insertions, 272 deletions
diff --git a/hl/src/H5DS.c b/hl/src/H5DS.c
index 902fb9b..8707f2c 100644
--- a/hl/src/H5DS.c
+++ b/hl/src/H5DS.c
@@ -273,26 +273,20 @@ herr_t H5DSattach_scale(hid_t did,
if (H5Aread(aid,tid,buf)<0)
goto out;
- for(i=0; i<rank; i++)
+ /* we are adding one more DS to this dimension */
+ if ( buf[idx].len > 0 )
{
- if (idx == (unsigned int)i )
- {
- /* we are adding one more DS to this dimension */
- if ( buf[i].len > 0 )
- {
- buf[i].len++;
- len = buf[i].len;
- buf[i].p = realloc( buf[i].p, len * sizeof(hobj_ref_t));
- ((hobj_ref_t *)buf[i].p)[ len-1 ] = ref;
- }
- else
- {
- /* store the REF information in the index of the dataset that has the DS */
- buf[idx].len = 1;
- buf[idx].p = malloc( 1 * sizeof(hobj_ref_t));
- ((hobj_ref_t *)buf[idx].p)[0] = ref;
- }
- }
+ buf[idx].len++;
+ len = buf[idx].len;
+ buf[idx].p = realloc( buf[idx].p, len * sizeof(hobj_ref_t));
+ ((hobj_ref_t *)buf[idx].p)[ len-1 ] = ref;
+ }
+ else
+ {
+ /* store the REF information in the index of the dataset that has the DS */
+ buf[idx].len = 1;
+ buf[idx].p = malloc( 1 * sizeof(hobj_ref_t));
+ ((hobj_ref_t *)buf[idx].p)[0] = ref;
}
/* write the attribute with the new references */
@@ -313,8 +307,6 @@ herr_t H5DSattach_scale(hid_t did,
} /* has_dimlist */
-
-
/*-------------------------------------------------------------------------
* save DS info on the >>DS<< dataset
*-------------------------------------------------------------------------
@@ -407,8 +399,16 @@ herr_t H5DSattach_scale(hid_t did,
if (H5Aread(aid,tid,dsbuf)<0)
goto out;
+ /* close */
if (H5Sclose(sid)<0)
goto out;
+ if (H5Aclose(aid)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
+ * create a new attribute
+ *-------------------------------------------------------------------------
+ */
/* the attribute must be deleted, in order to the new one can reflect the changes*/
if (H5Adelete(dsid,REFERENCE_LIST)<0)
@@ -442,7 +442,6 @@ herr_t H5DSattach_scale(hid_t did,
free(dsbuf);
} /* has_dimlist */
-
/*-------------------------------------------------------------------------
* write the standard attributes for a Dimension Scale dataset
@@ -468,11 +467,8 @@ out:
H5Tclose(tid);
} H5E_END_TRY;
return FAIL;
-
}
-
-
/*-------------------------------------------------------------------------
* Function: H5DSdetach_scale
*
@@ -509,7 +505,7 @@ herr_t H5DSdetach_scale(hid_t did,
ds_list_t *dsbuf; /* array of attribute data in the DS pointing to the dataset */
hobj_ref_t ref; /* reference to the DS */
hvl_t *buf; /* VL buffer to store in the attribute */
- unsigned i, j;
+ unsigned i, j, jj;
H5G_stat_t sb1, sb2, sb3, sb4;
int found_dset=0, found_ds=0;
@@ -543,94 +539,9 @@ herr_t H5DSdetach_scale(hid_t did,
if (H5Sclose(sid)<0)
goto out;
-
-/*-------------------------------------------------------------------------
- * open it, and delete the reference
- *-------------------------------------------------------------------------
- */
-
- else if ( has_dimlist == 1 )
- {
- if ((aid = H5Aopen_name(did,DIMENSION_LIST))<0)
- goto out;
-
- if ((tid = H5Aget_type(aid))<0)
- goto out;
-
- if ((sid = H5Aget_space(aid))<0)
- goto out;
-
- /* allocate and initialize the VL */
- buf = (hvl_t*)malloc((size_t)rank * sizeof(hvl_t));
-
- if (buf == NULL)
- goto out;
-
- /* read */
- if (H5Aread(aid,tid,buf)<0)
- goto out;
- for(i=0; i<(unsigned int)rank; i++)
- {
- if (idx == i )
- {
- /* reset */
- if ( buf[i].len > 0 )
- {
- for(j=0; j<buf[i].len; j++)
- {
- /* get the reference */
- ref = ((hobj_ref_t *)buf[i].p)[j];
-
- /* get the DS id */
- if ((dsid_j = H5Rdereference(did,H5R_OBJECT,&ref))<0)
- goto out;
-
- /* get info for DS in the parameter list */
- if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0)
- goto out;
-
- /* get info for this DS */
- if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0)
- goto out;
-
- /* same object, reset */
- if (sb1.fileno==sb2.fileno && sb1.objno==sb2.objno) {
- ((hobj_ref_t *)buf[i].p)[j] = 0;
- found_ds = 1;
- }
-
- /* close the dereferenced dataset */
- if (H5Dclose(dsid_j)<0)
- goto out;
- } /* j */
- } /* if */
- } /* if */
- } /* i */
-
- if (found_ds == 0)
- goto out;
-
- /* write the attribute */
- if (H5Awrite(aid,tid,buf)<0)
- goto out;
-
- /* close */
- if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf)<0)
- goto out;
- if (H5Sclose(sid)<0)
- goto out;
- if (H5Tclose(tid)<0)
- goto out;
- if (H5Aclose(aid)<0)
- goto out;
- if (buf)
- free(buf);
-
- } /* has_dimlist */
-
/*-------------------------------------------------------------------------
- * save DS info on the >>DS<< dataset
+ * find "REFERENCE_LIST"
*-------------------------------------------------------------------------
*/
@@ -638,92 +549,162 @@ herr_t H5DSdetach_scale(hid_t did,
if ((has_reflist = H5LT_find_attribute(dsid,REFERENCE_LIST))<0)
goto out;
-/*-------------------------------------------------------------------------
- * it does not exist
- *-------------------------------------------------------------------------
- */
if (has_reflist == 0)
goto out;
-
+
/*-------------------------------------------------------------------------
- * the "REFERENCE_LIST" array exists, update
+ * open "DIMENSION_LIST", and delete the reference
*-------------------------------------------------------------------------
*/
- else if ( has_reflist == 1 )
+
+ if ((aid = H5Aopen_name(did,DIMENSION_LIST))<0)
+ goto out;
+
+ if ((tid = H5Aget_type(aid))<0)
+ goto out;
+
+ if ((sid = H5Aget_space(aid))<0)
+ goto out;
+
+ /* allocate and initialize the VL */
+ buf = (hvl_t*)malloc((size_t)rank * sizeof(hvl_t));
+
+ if (buf == NULL)
+ goto out;
+
+ /* read */
+ if (H5Aread(aid,tid,buf)<0)
+ goto out;
+
+ /* reset */
+ if ( buf[idx].len > 0 )
{
- if ((aid = H5Aopen_name(dsid,REFERENCE_LIST))<0)
- goto out;
-
- if ((tid = H5Aget_type(aid))<0)
- goto out;
-
- /* get and save the old reference(s) */
- if ((sid = H5Aget_space(aid))<0)
- goto out;
-
- if ((nelmts = H5Sget_simple_extent_npoints(sid))<0)
- goto out;
-
- dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t));
-
- if (dsbuf == NULL)
- goto out;
-
- if (H5Aread(aid,tid,dsbuf)<0)
- goto out;
-
- for(i=0; i<nelmts; i++)
+ for(j=0; j<buf[idx].len; j++)
{
/* get the reference */
- ref = dsbuf[i].ref;
+ ref = ((hobj_ref_t *)buf[idx].p)[j];
/* get the DS id */
if ((dsid_j = H5Rdereference(did,H5R_OBJECT,&ref))<0)
goto out;
- /* get info for dataset in the parameter list */
- if (H5Gget_objinfo(did,".",TRUE,&sb3)<0)
+ /* get info for DS in the parameter list */
+ if (H5Gget_objinfo(dsid,".",TRUE,&sb1)<0)
goto out;
/* get info for this DS */
- if (H5Gget_objinfo(dsid_j,".",TRUE,&sb4)<0)
+ if (H5Gget_objinfo(dsid_j,".",TRUE,&sb2)<0)
goto out;
/* same object, reset */
- if (sb3.fileno==sb4.fileno && sb3.objno==sb4.objno) {
- dsbuf[i].ref=0;
- dsbuf[i].dim_idx=-1;
- found_dset=1;
- } /* if */
-
+ if (sb1.fileno==sb2.fileno && sb1.objno==sb2.objno)
+ {
+ for(jj=j; jj<buf[idx].len-1; jj++)
+ {
+ ((hobj_ref_t *)buf[idx].p)[jj] = ((hobj_ref_t *)buf[idx].p)[jj+1];
+ }
+ buf[idx].len--;
+
+ found_ds = 1;
+ }
+
/* close the dereferenced dataset */
if (H5Dclose(dsid_j)<0)
goto out;
- } /* i */
-
- if (found_dset == 0)
- goto out;
+ } /* j */
+ } /* if */
+
+ if (found_ds == 0)
+ goto out;
+
+ /* write the attribute */
+ if (H5Awrite(aid,tid,buf)<0)
+ goto out;
+
+ /* close */
+ if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf)<0)
+ goto out;
+ if (H5Sclose(sid)<0)
+ goto out;
+ if (H5Tclose(tid)<0)
+ goto out;
+ if (H5Aclose(aid)<0)
+ goto out;
+ if (buf)
+ free(buf);
- /* update on disk */
- if (H5Awrite(aid,tid,dsbuf)<0)
- goto out;
+/*-------------------------------------------------------------------------
+ * the "REFERENCE_LIST" array exists, update
+ *-------------------------------------------------------------------------
+ */
- /* close */
- if (H5Sclose(sid)<0)
+ if ((aid = H5Aopen_name(dsid,REFERENCE_LIST))<0)
+ goto out;
+
+ if ((tid = H5Aget_type(aid))<0)
+ goto out;
+
+ /* get and save the old reference(s) */
+ if ((sid = H5Aget_space(aid))<0)
+ goto out;
+
+ if ((nelmts = H5Sget_simple_extent_npoints(sid))<0)
+ goto out;
+
+ dsbuf = malloc((size_t)nelmts * sizeof(ds_list_t));
+
+ if (dsbuf == NULL)
+ goto out;
+
+ if (H5Aread(aid,tid,dsbuf)<0)
+ goto out;
+
+ for(i=0; i<nelmts; i++)
+ {
+ /* get the reference */
+ ref = dsbuf[i].ref;
+
+ /* get the DS id */
+ if ((dsid_j = H5Rdereference(did,H5R_OBJECT,&ref))<0)
goto out;
- if (H5Tclose(tid)<0)
+
+ /* get info for dataset in the parameter list */
+ if (H5Gget_objinfo(did,".",TRUE,&sb3)<0)
goto out;
- if (H5Aclose(aid)<0)
+
+ /* get info for this DS */
+ if (H5Gget_objinfo(dsid_j,".",TRUE,&sb4)<0)
goto out;
- if (dsbuf)
- free(dsbuf);
-
- if (found_dset == 0)
+ /* same object, reset */
+ if (sb3.fileno==sb4.fileno && sb3.objno==sb4.objno) {
+ dsbuf[i].ref=0;
+ dsbuf[i].dim_idx=-1;
+ found_dset=1;
+ } /* if */
+
+ /* close the dereferenced dataset */
+ if (H5Dclose(dsid_j)<0)
goto out;
-
- } /* has_dimlist */
-
+ } /* i */
+
+ if (found_dset == 0)
+ goto out;
+
+ /* update on disk */
+ if (H5Awrite(aid,tid,dsbuf)<0)
+ goto out;
+
+ /* close */
+ if (H5Sclose(sid)<0)
+ goto out;
+ if (H5Tclose(tid)<0)
+ goto out;
+ if (H5Aclose(aid)<0)
+ goto out;
+ if (dsbuf)
+ free(dsbuf);
+
return SUCCESS;
/* error zone, gracefully close */
@@ -767,8 +748,6 @@ herr_t H5DSget_nscales(hid_t did,
hid_t aid; /* attribute ID */
int rank; /* rank of dataset */
hvl_t *buf; /* VL buffer to store in the attribute */
- hobj_ref_t ref; /* reference to the DS */
- int i, n;
/*-------------------------------------------------------------------------
* the attribute "DIMENSION_LIST" on the >>data<< dataset must exist
@@ -822,13 +801,7 @@ herr_t H5DSget_nscales(hid_t did,
if (H5Aread(aid,tid,buf)<0)
goto out;
- for(i=0,n=0; i<(int)buf[dim].len; i++)
- {
- ref = ((hobj_ref_t *)buf[dim].p)[i];
- if (ref) n++;
- }
- /* return value */
- *nscales =n;
+ *nscales=(int)buf[dim].len;
/* close */
if (H5Dvlen_reclaim(tid,sid,H5P_DEFAULT,buf)<0)
@@ -855,7 +828,6 @@ out:
H5Tclose(tid);
} H5E_END_TRY;
return FAIL;
-
}
@@ -1018,9 +990,6 @@ out:
return FAIL;
}
-
-
-
/*-------------------------------------------------------------------------
* Function: H5DSget_label
*
@@ -1038,9 +1007,6 @@ out:
*
*-------------------------------------------------------------------------
*/
-
-
-
herr_t H5DSget_label(hid_t did,
char *label,
unsigned int idx)
@@ -1381,7 +1347,6 @@ herr_t H5DSiterate_scales(hid_t did,
if (idx!=NULL) *idx = i;
break;
}
-
} /* i */
} /* if */
diff --git a/hl/test/test_ds.c b/hl/test/test_ds.c
index 8ab29da..9290844 100644
--- a/hl/test/test_ds.c
+++ b/hl/test/test_ds.c
@@ -105,7 +105,7 @@ static int test_simple(void)
goto out;
/*-------------------------------------------------------------------------
- * create 6 datasets: two "data" datasets and 4 dimension scales
+ * create datasets: 1 "data" dataset and 4 dimension scales
*-------------------------------------------------------------------------
*/
@@ -113,24 +113,20 @@ static int test_simple(void)
if (H5LTmake_dataset_int(fid,"dset_a",rank,dims,buf)<0)
goto out;
- /* make a dataset */
- if (H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf)<0)
- goto out;
-
/* make a DS dataset for the first dimension */
- if (H5LTmake_dataset_int(fid,"ds1",rankds,s1_dim,s1_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_a_1",rankds,s1_dim,s1_wbuf)<0)
goto out;
/* make a DS dataset for the second dimension */
- if (H5LTmake_dataset_int(fid,"ds2",rankds,s2_dim,s2_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_a_2",rankds,s2_dim,s2_wbuf)<0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if (H5LTmake_dataset_int(fid,"ds21",rankds,s2_dim,s2_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_a_21",rankds,s2_dim,s2_wbuf)<0)
goto out;
/* make a DS dataset with an alternate scale for the 2nd dimension */
- if (H5LTmake_dataset_int(fid,"ds22",rankds,s2_dim,s2_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_a_22",rankds,s2_dim,s2_wbuf)<0)
goto out;
@@ -151,10 +147,10 @@ static int test_simple(void)
*/
/* get the DS dataset id */
- if ((dsid = H5Dopen(fid,"ds1"))<0)
+ if ((dsid = H5Dopen(fid,"ds_a_1"))<0)
goto out;
- /* attach the "ds1" dimension scale to "dset_a" as the 1st dimension */
+ /* attach the "ds_a_1" dimension scale to "dset_a" as the 1st dimension */
if (H5DSattach_scale(did,dsid,0)<0)
goto out;
@@ -163,12 +159,12 @@ static int test_simple(void)
goto out;
/*-------------------------------------------------------------------------
- * attach the "ds2" dimension scale to "dset_a"
+ * attach the "ds_a_2" dimension scale to "dset_a"
*-------------------------------------------------------------------------
*/
/* get the DS dataset id */
- if ((dsid = H5Dopen(fid,"ds2"))<0)
+ if ((dsid = H5Dopen(fid,"ds_a_2"))<0)
goto out;
/* attach the "ds2" dimension scale to "dset_a" as the 2nd dimension */
@@ -180,15 +176,15 @@ static int test_simple(void)
goto out;
/*-------------------------------------------------------------------------
- * attach the "ds21" dimension scale to "dset_a"
+ * attach the "ds_a_21" dimension scale to "dset_a"
*-------------------------------------------------------------------------
*/
/* get the DS dataset id */
- if ((dsid = H5Dopen(fid,"ds21"))<0)
+ if ((dsid = H5Dopen(fid,"ds_a_21"))<0)
goto out;
- /* attach the "ds21" dimension scale to "dset_a" as the 2nd dimension */
+ /* attach the "ds_a_21" dimension scale to "dset_a" as the 2nd dimension */
if (H5DSattach_scale(did,dsid,1)<0)
goto out;
@@ -197,12 +193,12 @@ static int test_simple(void)
goto out;
/*-------------------------------------------------------------------------
- * attach the "ds22" dimension scale to "dset_a"
+ * attach the "ds_a_22" dimension scale to "dset_a"
*-------------------------------------------------------------------------
*/
/* get the DS dataset id */
- if ((dsid = H5Dopen(fid,"ds22"))<0)
+ if ((dsid = H5Dopen(fid,"ds_a_22"))<0)
goto out;
/* attach the "ds22" dimension scale to "dset_a" as the 2nd dimension */
@@ -216,59 +212,35 @@ static int test_simple(void)
/* close dataset ID of "dset_a" */
if (H5Dclose(did)<0)
goto out;
-
-/*-------------------------------------------------------------------------
- * attach the "ds1" dimension scale to "dset_b"
- *-------------------------------------------------------------------------
- */
-
- /* get the dataset id for "dset_b" */
- if ((did = H5Dopen(fid,"dset_b"))<0)
- goto out;
-
- /* get the DS dataset id */
- if ((dsid = H5Dopen(fid,"ds1"))<0)
- goto out;
-
- /* attach the "ds1" dimension scale to "dset_b" as the 1st dimension */
- if (H5DSattach_scale(did,dsid,0)<0)
- goto out;
- /* close DS id */
- if (H5Dclose(dsid)<0)
- goto out;
-
- /* close dataset ID of "dset_b" */
- if (H5Dclose(did)<0)
- goto out;
/*-------------------------------------------------------------------------
* verify if the dimension scales are valid
*-------------------------------------------------------------------------
*/
- if ((did = H5Dopen(fid,"ds1"))<0)
+ if ((did = H5Dopen(fid,"ds_a_1"))<0)
goto out;
if ((H5DSis_scale(did))<=0)
goto out;
if (H5Dclose(did))
goto out;
- if ((did = H5Dopen(fid,"ds2"))<0)
+ if ((did = H5Dopen(fid,"ds_a_2"))<0)
goto out;
if ((H5DSis_scale(did))<=0)
goto out;
if (H5Dclose(did))
goto out;
- if ((did = H5Dopen(fid,"ds21"))<0)
+ if ((did = H5Dopen(fid,"ds_a_21"))<0)
goto out;
if ((H5DSis_scale(did))<=0)
goto out;
if (H5Dclose(did))
goto out;
- if ((did = H5Dopen(fid,"ds22"))<0)
+ if ((did = H5Dopen(fid,"ds_a_22"))<0)
goto out;
if ((H5DSis_scale(did))<=0)
goto out;
@@ -279,7 +251,6 @@ static int test_simple(void)
PASSED();
-
/*-------------------------------------------------------------------------
* test 2: get number of scales
*-------------------------------------------------------------------------
@@ -297,15 +268,13 @@ static int test_simple(void)
goto out;
/* verify that "dset_a" has 1 dimension scale at DIM 0 */
- dim=0;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ if (H5DSget_nscales(did,0,&nscales)<0)
goto out;
if (nscales!=1)
goto out;
/* verify that "dset_a" has 3 dimension scales at DIM 1 */
- dim=1;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ if (H5DSget_nscales(did,1,&nscales)<0)
goto out;
if (nscales!=3)
goto out;
@@ -316,6 +285,35 @@ static int test_simple(void)
/*-------------------------------------------------------------------------
+ * create datasets: 1 "data" dataset and 1 dimension scale
+ *-------------------------------------------------------------------------
+ */
+
+ /* make a dataset */
+ if (H5LTmake_dataset_int(fid,"dset_b",rank,dims,buf)<0)
+ goto out;
+
+ /* make a DS dataset for the first dimension */
+ if (H5LTmake_dataset_int(fid,"ds_b_1",rankds,s1_dim,s1_wbuf)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
+ * attach the scale to "dset_b"
+ *-------------------------------------------------------------------------
+ */
+
+ if ((did = H5Dopen(fid,"dset_b"))<0)
+ goto out;
+ if ((dsid = H5Dopen(fid,"ds_b_1"))<0)
+ goto out;
+ if (H5DSattach_scale(did,dsid,0)<0)
+ goto out;
+ if (H5Dclose(dsid)<0)
+ goto out;
+ if (H5Dclose(did)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
* verify if "dset_b" has dimension scales
*-------------------------------------------------------------------------
*/
@@ -325,15 +323,13 @@ static int test_simple(void)
goto out;
/* verify that "dset_b" has 1 dimension scale at DIM 0 */
- dim=0;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ if (H5DSget_nscales(did,0,&nscales)<0)
goto out;
if (nscales!=1)
goto out;
/* verify that "dset_b" has 0 dimension scales at DIM 1 */
- dim=1;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ if (H5DSget_nscales(did,1,&nscales)<0)
goto out;
if (nscales!=0)
goto out;
@@ -355,7 +351,7 @@ static int test_simple(void)
/*-------------------------------------------------------------------------
- * create 3 datasets: one "data" dataset and 2 dimension scales
+ * create datasets: one "data" dataset and 4 dimension scales
*-------------------------------------------------------------------------
*/
@@ -364,32 +360,58 @@ static int test_simple(void)
goto out;
/* make a DS dataset for the first dimension */
- if (H5LTmake_dataset_int(fid,"ds3",rankds,s1_dim,s1_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_c_1",rankds,s1_dim,s1_wbuf)<0)
goto out;
/* make a DS dataset for the second dimension */
- if (H5LTmake_dataset_int(fid,"ds4",rankds,s2_dim,s2_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_c_2",rankds,s2_dim,s2_wbuf)<0)
+ goto out;
+
+ /* make a DS dataset with an alternate scale for the 2nd dimension */
+ if (H5LTmake_dataset_int(fid,"ds_c_21",rankds,s2_dim,s2_wbuf)<0)
goto out;
+ /* make a DS dataset with an alternate scale for the 2nd dimension */
+ if (H5LTmake_dataset_int(fid,"ds_c_22",rankds,s2_dim,s2_wbuf)<0)
+ goto out;
+
+
/*-------------------------------------------------------------------------
- * attach "ds3" and "ds4" to "dset_c"
+ * attach the scales to "dset_c"
*-------------------------------------------------------------------------
*/
if ((did = H5Dopen(fid,"dset_c"))<0)
goto out;
- if ((dsid = H5Dopen(fid,"ds3"))<0)
+
+ if ((dsid = H5Dopen(fid,"ds_c_1"))<0)
goto out;
if (H5DSattach_scale(did,dsid,0)<0)
goto out;
if (H5Dclose(dsid)<0)
goto out;
- if ((dsid = H5Dopen(fid,"ds4"))<0)
+
+ if ((dsid = H5Dopen(fid,"ds_c_2"))<0)
goto out;
if (H5DSattach_scale(did,dsid,1)<0)
goto out;
if (H5Dclose(dsid)<0)
goto out;
+
+ if ((dsid = H5Dopen(fid,"ds_c_21"))<0)
+ goto out;
+ if (H5DSattach_scale(did,dsid,1)<0)
+ goto out;
+ if (H5Dclose(dsid)<0)
+ goto out;
+
+ if ((dsid = H5Dopen(fid,"ds_c_22"))<0)
+ goto out;
+ if (H5DSattach_scale(did,dsid,1)<0)
+ goto out;
+ if (H5Dclose(dsid)<0)
+ goto out;
+
if (H5Dclose(did)<0)
goto out;
@@ -401,22 +423,60 @@ static int test_simple(void)
if ((did = H5Dopen(fid,"dset_c"))<0)
goto out;
/* verify that "dset_c" has 1 dimension scale at DIM 0 */
- dim=0;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ if (H5DSget_nscales(did,0,&nscales)<0)
goto out;
if (nscales!=1)
goto out;
- /* verify that "dset_c" has 1 dimension scale at DIM 1 */
- dim=1;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ /* verify that "dset_c" has 3 dimension scales at DIM 1 */
+ if (H5DSget_nscales(did,1,&nscales)<0)
goto out;
- if (nscales!=1)
+ if (nscales!=3)
goto out;
if (H5Dclose(did)<0)
goto out;
/*-------------------------------------------------------------------------
- * detach the "ds3" dimension scale to "dset_c"
+ * detach the "ds_c_21" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
+
+ /* get the dataset id for "dset_c" */
+ if ((did = H5Dopen(fid,"dset_c"))<0)
+ goto out;
+
+ /* get the DS dataset id */
+ if ((dsid = H5Dopen(fid,"ds_c_21"))<0)
+ goto out;
+
+ /* detach the "ds_c_21" dimension scale to "dset_c" in DIM 1 */
+ if (H5DSdetach_scale(did,dsid,1)<0)
+ goto out;
+
+ /* close DS id */
+ if (H5Dclose(dsid)<0)
+ goto out;
+
+ /* close dataset ID of "dset_c" */
+ if (H5Dclose(did)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
+ * "dset_c" must have now 2 dimension scales at DIM 1
+ *-------------------------------------------------------------------------
+ */
+
+ if ((did = H5Dopen(fid,"dset_c"))<0)
+ goto out;
+ /* verify that "dset_c" has 2 dimension scales at DIM 1 */
+ if (H5DSget_nscales(did,1,&nscales)<0)
+ goto out;
+ if (nscales!=2)
+ goto out;
+ if (H5Dclose(did)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
+ * detach the "ds_c_22" dimension scale to "dset_c"
*-------------------------------------------------------------------------
*/
@@ -425,11 +485,11 @@ static int test_simple(void)
goto out;
/* get the DS dataset id */
- if ((dsid = H5Dopen(fid,"ds3"))<0)
+ if ((dsid = H5Dopen(fid,"ds_c_22"))<0)
goto out;
- /* detach the "ds3" dimension scale to "dset_c" at index 0 */
- if (H5DSdetach_scale(did,dsid,0)<0)
+ /* detach the "ds_c_22" dimension scale to "dset_c" in DIM 1 */
+ if (H5DSdetach_scale(did,dsid,1)<0)
goto out;
/* close DS id */
@@ -441,21 +501,61 @@ static int test_simple(void)
goto out;
/*-------------------------------------------------------------------------
- * verify that "dset_c" has NOT dimension scales
+ * "dset_c" must have now 1 dimension scale at DIM 1
*-------------------------------------------------------------------------
*/
if ((did = H5Dopen(fid,"dset_c"))<0)
goto out;
- /* verify that "dset_c" has 0 dimension scale at DIM 0 */
- dim=0;
- if (H5DSget_nscales(did,dim,&nscales)<0)
+ /* verify that "dset_c" has 1 dimension scale at DIM 1 */
+ if (H5DSget_nscales(did,1,&nscales)<0)
+ goto out;
+ if (nscales!=1)
+ goto out;
+ if (H5Dclose(did)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
+ * detach the "ds_c_2" dimension scale to "dset_c"
+ *-------------------------------------------------------------------------
+ */
+
+ /* get the dataset id for "dset_c" */
+ if ((did = H5Dopen(fid,"dset_c"))<0)
+ goto out;
+
+ /* get the DS dataset id */
+ if ((dsid = H5Dopen(fid,"ds_c_2"))<0)
+ goto out;
+
+ /* detach the "ds_c_2" dimension scale to "dset_c" in DIM 1 */
+ if (H5DSdetach_scale(did,dsid,1)<0)
+ goto out;
+
+ /* close DS id */
+ if (H5Dclose(dsid)<0)
+ goto out;
+
+ /* close dataset ID of "dset_c" */
+ if (H5Dclose(did)<0)
+ goto out;
+
+/*-------------------------------------------------------------------------
+ * "dset_c" must have now 0 dimension scales at DIM 1
+ *-------------------------------------------------------------------------
+ */
+
+ if ((did = H5Dopen(fid,"dset_c"))<0)
+ goto out;
+ /* verify that "dset_c" has 1 dimension scale at DIM 1 */
+ if (H5DSget_nscales(did,1,&nscales)<0)
goto out;
if (nscales!=0)
goto out;
if (H5Dclose(did)<0)
goto out;
+
PASSED();
/*-------------------------------------------------------------------------
@@ -499,19 +599,19 @@ static int test_simple(void)
TESTING2("set scale/get scale name");
/*-------------------------------------------------------------------------
- * make a dataset named "ds5" and convert it to a DS dataset
+ * make a dataset named "ds_1" and convert it to a DS dataset
*-------------------------------------------------------------------------
*/
- if (H5LTmake_dataset_int(fid,"ds5",rankds,s1_dim,s1_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_1",rankds,s1_dim,s1_wbuf)<0)
goto out;
- if ((did = H5Dopen(fid,"ds5"))<0)
+ if ((did = H5Dopen(fid,"ds_1"))<0)
goto out;
if (H5DSset_scale(did,"scale 1")<0)
goto out;
- /* verify that "ds5" is a dimension scale dataset */
+ /* verify that "ds5_1" is a dimension scale dataset */
if ((H5DSis_scale(did))==0)
goto out;
@@ -629,7 +729,7 @@ static int test_simple(void)
if (match_size==0)
goto out;
- /* both "ds1" and "ds2" are the on the first index */
+ /* both "ds_a_1" and "ds_a_2" are the on the first index */
if (idx!=0)
goto out;
}
@@ -656,11 +756,11 @@ static int test_simple(void)
*/
if (H5LTmake_dataset_int(fid,"dset_d",rank,dims,buf)<0)
goto out;
- if (H5LTmake_dataset_int(fid,"ds6_1_1",rankds,s1_dim,NULL)<0)
+ if (H5LTmake_dataset_int(fid,"ds_d_1",rankds,s1_dim,NULL)<0)
goto out;
- if (H5LTmake_dataset_int(fid,"ds6_1_2",rankds,s1_dim,s1_wbuf)<0)
+ if (H5LTmake_dataset_int(fid,"ds_d_11",rankds,s1_dim,s1_wbuf)<0)
goto out;
- if (H5LTmake_dataset_int(fid,"ds7_2_1",rankds,s2_dim,NULL)<0)
+ if (H5LTmake_dataset_int(fid,"ds_d_2",rankds,s2_dim,NULL)<0)
goto out;
/*-------------------------------------------------------------------------
@@ -670,19 +770,19 @@ static int test_simple(void)
if ((did = H5Dopen(fid,"dset_d"))<0)
goto out;
- if ((dsid = H5Dopen(fid,"ds6_1_1"))<0)
+ if ((dsid = H5Dopen(fid,"ds_d_1"))<0)
goto out;
if (H5DSattach_scale(did,dsid,0)<0)
goto out;
if (H5Dclose(dsid)<0)
goto out;
- if ((dsid = H5Dopen(fid,"ds6_1_2"))<0)
+ if ((dsid = H5Dopen(fid,"ds_d_11"))<0)
goto out;
if (H5DSattach_scale(did,dsid,0)<0)
goto out;
if (H5Dclose(dsid)<0)
goto out;
- if ((dsid = H5Dopen(fid,"ds7_2_1"))<0)
+ if ((dsid = H5Dopen(fid,"ds_d_2"))<0)
goto out;
if (H5DSattach_scale(did,dsid,1)<0)
goto out;