diff options
Diffstat (limited to 'testpar')
-rw-r--r-- | testpar/t_dset.c | 85 | ||||
-rw-r--r-- | testpar/testphdf5.h | 1 |
2 files changed, 80 insertions, 6 deletions
diff --git a/testpar/t_dset.c b/testpar/t_dset.c index c65ee11..a65a3ae 100644 --- a/testpar/t_dset.c +++ b/testpar/t_dset.c @@ -479,7 +479,7 @@ dataset_writeAll(char *filename) hid_t sid; /* Dataspace ID */ hid_t file_dataspace; /* File dataspace ID */ hid_t mem_dataspace; /* memory dataspace ID */ - hid_t dataset1, dataset2, dataset3; /* Dataset ID */ + hid_t dataset1, dataset2, dataset3, dataset4; /* Dataset ID */ hid_t datatype; /* Datatype ID */ hsize_t dims[RANK]; /* dataset dim sizes */ DATATYPE *data_array1 = NULL; /* data buffer */ @@ -525,7 +525,7 @@ dataset_writeAll(char *filename) * Define the dimensions of the overall datasets * and create the dataset * ------------------------- */ - /* setup dimensionality object */ + /* setup 2-D dimensionality object */ dims[0] = dim0; dims[1] = dim1; sid = H5Screate_simple (RANK, dims, NULL); @@ -546,7 +546,21 @@ dataset_writeAll(char *filename) /* create a third dataset collectively */ dataset3 = H5Dcreate(fid, DATASETNAME3, H5T_NATIVE_INT, sid, H5P_DEFAULT); - VRFY((dataset1 >= 0), "H5Dcreate succeeded"); + VRFY((dataset3 >= 0), "H5Dcreate succeeded"); + + /* release 2-D space ID created */ + H5Sclose(sid); + + /* setup scalar dimensionality object */ + sid = H5Screate(H5S_SCALAR); + VRFY((sid >= 0), "H5Screate succeeded"); + + /* create a fourth dataset collectively */ + dataset4 = H5Dcreate(fid, DATASETNAME4, H5T_NATIVE_INT, sid, H5P_DEFAULT); + VRFY((dataset4 >= 0), "H5Dcreate succeeded"); + + /* release scalar space ID created */ + H5Sclose(sid); /* * Set up dimensions of the slab this process accesses. @@ -722,6 +736,66 @@ dataset_writeAll(char *filename) VRFY((ret >= 0), "H5Dwrite dataset3 succeeded"); /* release all temporary handles. */ + /* Could have used them for dataset4 but it is cleaner */ + /* to create them again.*/ + H5Sclose(file_dataspace); + H5Sclose(mem_dataspace); + H5Pclose(xfer_plist); + + /* Dataset4: each process writes no data, except process zero uses "all" selection. */ + /* Additionally, these are in a scalar dataspace */ + + /* create a file dataspace independently */ + file_dataspace = H5Dget_space (dataset4); + VRFY((file_dataspace >= 0), "H5Dget_space succeeded"); + if (MAINPROCESS) { + ret=H5Sselect_none(file_dataspace); + VRFY((ret >= 0), "H5Sselect_all file_dataspace succeeded"); + } /* end if */ + else { + ret=H5Sselect_all(file_dataspace); + VRFY((ret >= 0), "H5Sselect_none succeeded"); + } /* end else */ + + /* create a memory dataspace independently */ + mem_dataspace = H5Screate(H5S_SCALAR); + VRFY((mem_dataspace >= 0), ""); + if (MAINPROCESS) { + ret=H5Sselect_none(mem_dataspace); + VRFY((ret >= 0), "H5Sselect_all mem_dataspace succeeded"); + } /* end if */ + else { + ret=H5Sselect_all(mem_dataspace); + VRFY((ret >= 0), "H5Sselect_none succeeded"); + } /* end else */ + + /* fill the local slab with some trivial data */ + dataset_fill(start, block, data_array1); + MESG("data_array initialized"); + if (verbose) { + MESG("data_array created"); + dataset_print(start, block, data_array1); + } /* end if */ + + /* set up the collective transfer properties list */ + xfer_plist = H5Pcreate (H5P_DATASET_XFER); + VRFY((xfer_plist >= 0), ""); + ret=H5Pset_dxpl_mpio(xfer_plist, H5FD_MPIO_COLLECTIVE); + VRFY((ret >= 0), "H5Pcreate xfer succeeded"); + + /* write data collectively */ + MESG("writeAll with scalar dataspace"); + ret = H5Dwrite(dataset4, H5T_NATIVE_INT, mem_dataspace, file_dataspace, + xfer_plist, data_array1); + VRFY((ret >= 0), "H5Dwrite dataset4 succeeded"); + + /* write data collectively (with datatype conversion) */ + MESG("writeAll with scalar dataspace"); + ret = H5Dwrite(dataset4, H5T_NATIVE_UCHAR, mem_dataspace, file_dataspace, + xfer_plist, data_array1); + VRFY((ret >= 0), "H5Dwrite dataset4 succeeded"); + + /* release all temporary handles. */ H5Sclose(file_dataspace); H5Sclose(mem_dataspace); H5Pclose(xfer_plist); @@ -735,9 +809,8 @@ dataset_writeAll(char *filename) VRFY((ret >= 0), "H5Dclose2 succeeded"); ret=H5Dclose(dataset3); VRFY((ret >= 0), "H5Dclose3 succeeded"); - - /* release all IDs created */ - H5Sclose(sid); + ret=H5Dclose(dataset4); + VRFY((ret >= 0), "H5Dclose3 succeeded"); /* close the file collectively */ H5Fclose(fid); diff --git a/testpar/testphdf5.h b/testpar/testphdf5.h index 1e0e47a..57d6112 100644 --- a/testpar/testphdf5.h +++ b/testpar/testphdf5.h @@ -72,6 +72,7 @@ #define DATASETNAME1 "Data1" #define DATASETNAME2 "Data2" #define DATASETNAME3 "Data3" +#define DATASETNAME4 "Data4" /* hyperslab layout styles */ #define BYROW 1 /* divide into slabs of rows */ #define BYCOL 2 /* divide into blocks of columns */ |