diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2005-08-13 20:53:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2005-08-13 20:53:35 (GMT) |
commit | 6b45f5172ccb4311e0be9ae15da3758abb6b0e67 (patch) | |
tree | 5a7a112fe7a8a98c6fecb45b513789d15962eb3d /c++/examples | |
parent | 6562465a2c2a58cfbc2f47bf60bb538f7a783933 (diff) | |
download | hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.zip hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.gz hdf5-6b45f5172ccb4311e0be9ae15da3758abb6b0e67.tar.bz2 |
[svn-r11245] Purpose:
Code cleanup
Description:
Trim trailing whitespace, which is making 'diff'ing the two branches
difficult.
Solution:
Ran this script in each directory:
foreach f (*.[ch] *.cpp)
sed 's/[[:blank:]]*$//' $f > sed.out && mv sed.out $f
end
Platforms tested:
FreeBSD 4.11 (sleipnir)
Too minor to require h5committest
Diffstat (limited to 'c++/examples')
-rw-r--r-- | c++/examples/chunks.cpp | 80 | ||||
-rw-r--r-- | c++/examples/compound.cpp | 16 | ||||
-rw-r--r-- | c++/examples/create.cpp | 18 | ||||
-rw-r--r-- | c++/examples/extend_ds.cpp | 48 | ||||
-rw-r--r-- | c++/examples/h5group.cpp | 28 | ||||
-rw-r--r-- | c++/examples/readdata.cpp | 20 | ||||
-rw-r--r-- | c++/examples/writedata.cpp | 48 |
7 files changed, 129 insertions, 129 deletions
diff --git a/c++/examples/chunks.cpp b/c++/examples/chunks.cpp index 0efd95d..b6db2ad 100644 --- a/c++/examples/chunks.cpp +++ b/c++/examples/chunks.cpp @@ -12,11 +12,11 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* +/* * This example shows how to read data from a chunked dataset. - * We will read from the file created by extend.C + * We will read from the file created by extend.C */ - + #include <string> #ifdef OLD_HEADER_FILENAME @@ -55,7 +55,7 @@ int main (void) */ H5File file( FILE_NAME, H5F_ACC_RDONLY ); DataSet dataset = file.openDataSet( DATASET_NAME ); - + /* * Get filespace for rank and dimension */ @@ -69,18 +69,18 @@ int main (void) /* * Get and print the dimension sizes of the file dataspace */ - hsize_t dims[2]; // dataset dimensions + hsize_t dims[2]; // dataset dimensions rank = filespace.getSimpleExtentDims( dims ); - cout << "dataset rank = " << rank << ", dimensions " + cout << "dataset rank = " << rank << ", dimensions " << (unsigned long)(dims[0]) << " x " << (unsigned long)(dims[1]) << endl; /* * Get creation properties list. */ - DSetCreatPropList cparms = dataset.getCreatePlist(); + DSetCreatPropList cparms = dataset.getCreatePlist(); - /* + /* * Check if dataset is chunked. */ hsize_t chunk_dims[2]; @@ -91,16 +91,16 @@ int main (void) * Get chunking information: rank and dimensions */ rank_chunk = cparms.getChunk( 2, chunk_dims); - cout << "chunk rank " << rank_chunk << "dimensions " - << (unsigned long)(chunk_dims[0]) << " x " + cout << "chunk rank " << rank_chunk << "dimensions " + << (unsigned long)(chunk_dims[0]) << " x " << (unsigned long)(chunk_dims[1]) << endl; } - + /* * Define the memory space to read dataset. */ DataSpace mspace1( RANK, dims ); - + /* * Read dataset back and display. */ @@ -113,23 +113,23 @@ int main (void) for (i = 0; i < dims[1]; i++) cout << data_out[j][i] << " "; cout << endl; - } + } /* - * dataset rank 2, dimensions 10 x 5 - * chunk rank 2, dimensions 2 x 5 + * dataset rank 2, dimensions 10 x 5 + * chunk rank 2, dimensions 2 x 5 * Dataset: - * 1 1 1 3 3 - * 1 1 1 3 3 - * 1 1 1 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 - * 2 0 0 0 0 + * 1 1 1 3 3 + * 1 1 1 3 3 + * 1 1 1 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 + * 2 0 0 0 0 */ /* @@ -157,17 +157,17 @@ int main (void) cout << column[i] << endl; /* - * Third column: - * 1 - * 1 - * 1 - * 0 - * 0 - * 0 - * 0 - * 0 - * 0 - * 0 + * Third column: + * 1 + * 1 + * 1 + * 0 + * 0 + * 0 + * 0 + * 0 + * 0 + * 0 */ /* @@ -196,11 +196,11 @@ int main (void) for (i = 0; i < chunk_dims[1]; i++) cout << chunk_out[j][i] << " "; cout << endl; - } + } /* - * Chunk: - * 1 1 1 0 0 - * 2 0 0 0 0 + * Chunk: + * 1 1 1 0 0 + * 2 0 0 0 0 */ } // end of try block diff --git a/c++/examples/compound.cpp b/c++/examples/compound.cpp index d3163d6..dfbd544 100644 --- a/c++/examples/compound.cpp +++ b/c++/examples/compound.cpp @@ -45,7 +45,7 @@ int main(void) typedef struct s1_t { int a; float b; - double c; + double c; } s1_t; /* Second structure (subset of s1_t) and dataset*/ @@ -87,21 +87,21 @@ int main(void) H5File* file = new H5File( FILE_NAME, H5F_ACC_TRUNC ); /* - * Create the memory datatype. + * Create the memory datatype. */ CompType mtype1( sizeof(s1_t) ); mtype1.insertMember( MEMBER1, HOFFSET(s1_t, a), PredType::NATIVE_INT); mtype1.insertMember( MEMBER3, HOFFSET(s1_t, c), PredType::NATIVE_DOUBLE); mtype1.insertMember( MEMBER2, HOFFSET(s1_t, b), PredType::NATIVE_FLOAT); - /* + /* * Create the dataset. */ DataSet* dataset; dataset = new DataSet( file->createDataSet( DATASET_NAME, mtype1, space )); /* - * Wtite data to the dataset; + * Wtite data to the dataset; */ dataset->write( s1, mtype1 ); @@ -110,7 +110,7 @@ int main(void) */ delete dataset; delete file; - + // Get the class of the first member in mtype1, then get its type H5T_class_t member1_class = mtype1.getMemberClass( 2 ); if( member1_class == H5T_FLOAT ) @@ -127,7 +127,7 @@ int main(void) file = new H5File( FILE_NAME, H5F_ACC_RDONLY ); dataset = new DataSet (file->openDataSet( DATASET_NAME )); - /* + /* * Create a datatype for s2 */ CompType mtype2( sizeof(s2_t) ); @@ -151,11 +151,11 @@ int main(void) cout << endl; cout << endl << "Field a : " << endl; - for( i = 0; i < LENGTH; i++) + for( i = 0; i < LENGTH; i++) cout << s2[i].a << " "; cout << endl; - /* + /* * Create a datatype for s3. */ CompType mtype3( sizeof(float) ); diff --git a/c++/examples/create.cpp b/c++/examples/create.cpp index 06d5d4d..3e93cb4 100644 --- a/c++/examples/create.cpp +++ b/c++/examples/create.cpp @@ -12,10 +12,10 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* +/* * This example writes a dataset to a new HDF5 file. */ - + #include <string> #ifdef OLD_HEADER_FILENAME @@ -37,8 +37,8 @@ const int RANK = 2; int main (void) { - /* - * Data initialization. + /* + * Data initialization. */ int i, j; int data[NX][NY]; // buffer for data to write @@ -46,9 +46,9 @@ int main (void) { for (i = 0; i < NY; i++) data[j][i] = i + j; - } + } /* - * 0 1 2 3 4 5 + * 0 1 2 3 4 5 * 1 2 3 4 5 6 * 2 3 4 5 6 7 * 3 4 5 6 7 8 @@ -73,12 +73,12 @@ int main (void) /* * Define the size of the array and create the data space for fixed - * size dataset. + * size dataset. */ hsize_t dimsf[2]; // dataset dimensions dimsf[0] = NX; dimsf[1] = NY; - DataSpace dataspace( RANK, dimsf ); + DataSpace dataspace( RANK, dimsf ); /* * Define datatype for the data in the file. @@ -129,5 +129,5 @@ int main (void) } return 0; // successfully terminated -} +} diff --git a/c++/examples/extend_ds.cpp b/c++/examples/extend_ds.cpp index 9c12304..614a2b1 100644 --- a/c++/examples/extend_ds.cpp +++ b/c++/examples/extend_ds.cpp @@ -12,13 +12,13 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* +/* * This example shows how to work with extendible dataset. * In the current version of the library dataset MUST be * chunked. - * + * */ - + #include <string> #ifdef OLD_HEADER_FILENAME @@ -52,18 +52,18 @@ int main (void) Exception::dontPrint(); /* - * Create the data space with unlimited dimensions. + * Create the data space with unlimited dimensions. */ - hsize_t dims[2] = { 3, 3}; // dataset dimensions at creation + hsize_t dims[2] = { 3, 3}; // dataset dimensions at creation hsize_t maxdims[2] = {H5S_UNLIMITED, H5S_UNLIMITED}; - DataSpace mspace1( RANK, dims, maxdims); + DataSpace mspace1( RANK, dims, maxdims); /* * Create a new file. If file exists its contents will be overwritten. */ H5File file( FILE_NAME, H5F_ACC_TRUNC ); - /* + /* * Modify dataset creation properties, i.e. enable chunking. */ DSetCreatPropList cparms; @@ -87,8 +87,8 @@ int main (void) * Extend the dataset. This call assures that dataset is at least 3 x 3. */ hsize_t size[2]; - size[0] = 3; - size[1] = 3; + size[0] = 3; + size[1] = 3; dataset.extend( size ); /* @@ -98,24 +98,24 @@ int main (void) hsize_t offset[2]; offset[0] = 0; offset[1] = 0; - hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */ - fspace1.selectHyperslab( H5S_SELECT_SET, dims1, offset ); + hsize_t dims1[2] = { 3, 3}; /* data1 dimensions */ + fspace1.selectHyperslab( H5S_SELECT_SET, dims1, offset ); /* * Write the data to the hyperslab. */ int data1[3][3] = { {1, 1, 1}, /* data to write */ {1, 1, 1}, - {1, 1, 1} }; + {1, 1, 1} }; dataset.write( data1, PredType::NATIVE_INT, mspace1, fspace1 ); /* * Extend the dataset. Dataset becomes 10 x 3. */ - hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */ + hsize_t dims2[2] = { 7, 1}; /* data2 dimensions */ dims[0] = dims1[0] + dims2[0]; - size[0] = dims[0]; - size[1] = dims[1]; + size[0] = dims[0]; + size[1] = dims[1]; dataset.extend( size ); /* @@ -124,12 +124,12 @@ int main (void) DataSpace fspace2 = dataset.getSpace (); offset[0] = 3; offset[1] = 0; - fspace2.selectHyperslab( H5S_SELECT_SET, dims2, offset ); + fspace2.selectHyperslab( H5S_SELECT_SET, dims2, offset ); /* * Define memory space */ - DataSpace mspace2( RANK, dims2 ); + DataSpace mspace2( RANK, dims2 ); /* * Write the data to the hyperslab. @@ -140,10 +140,10 @@ int main (void) /* * Extend the dataset. Dataset becomes 10 x 5. */ - hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */ + hsize_t dims3[2] = { 2, 2}; /* data3 dimensions */ dims[1] = dims1[1] + dims3[1]; - size[0] = dims[0]; - size[1] = dims[1]; + size[0] = dims[0]; + size[1] = dims[1]; dataset.extend( size ); /* @@ -152,12 +152,12 @@ int main (void) DataSpace fspace3 = dataset.getSpace (); offset[0] = 0; offset[1] = 3; - fspace3.selectHyperslab( H5S_SELECT_SET, dims3, offset ); + fspace3.selectHyperslab( H5S_SELECT_SET, dims3, offset ); /* * Define memory space. */ - DataSpace mspace3( RANK, dims3 ); + DataSpace mspace3( RANK, dims3 ); /* * Write the data to the hyperslab. @@ -178,7 +178,7 @@ int main (void) dataset.read( data_out, PredType::NATIVE_INT ); /* * Resulting dataset - * + * * 1 1 1 3 3 * 1 1 1 3 3 * 1 1 1 0 0 @@ -229,4 +229,4 @@ int main (void) return -1; } return 0; -} +} diff --git a/c++/examples/h5group.cpp b/c++/examples/h5group.cpp index d7f3c66..a69f2f4 100644 --- a/c++/examples/h5group.cpp +++ b/c++/examples/h5group.cpp @@ -13,13 +13,13 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * This example creates a group in the file and dataset in the group. + * This example creates a group in the file and dataset in the group. * Hard link to the group object is created and the dataset is accessed - * under different names. + * under different names. * Iterator function is used to find the object names in the root group. * Note that the C++ API iterator function is not completed yet, thus * the C version is used in this example. - */ + */ #include <string> #ifdef OLD_HEADER_FILENAME @@ -67,9 +67,9 @@ int main(void) /* * Create dataset "Compressed Data" in the group using absolute - * name. Dataset creation property list is modified to use - * GZIP compression with the compression effort set to 6. - * Note that compression can be used only when dataset is chunked. + * name. Dataset creation property list is modified to use + * GZIP compression with the compression effort set to 6. + * Note that compression can be used only when dataset is chunked. */ dims[0] = 1000; dims[1] = 20; @@ -92,13 +92,13 @@ int main(void) delete file; /* - * Now reopen the file and group in the file. + * Now reopen the file and group in the file. */ file = new H5File( FILE_NAME, H5F_ACC_RDWR ); group = new Group( file->openGroup( "Data" )); /* - * Access "Compressed_Data" dataset in the group. + * Access "Compressed_Data" dataset in the group. */ try { // to determine if the dataset exists in the group dataset = new DataSet( group->openDataSet( "Compressed_Data" )); @@ -121,11 +121,11 @@ int main(void) /* * We can access "Compressed_Data" dataset using created - * hard link "Data_new". + * hard link "Data_new". */ try { // to determine if the dataset exists in the file dataset = new DataSet( file->openDataSet( "/Data_new/Compressed_Data" )); - } + } catch( FileIException not_found_error ) { cout << " Dataset is not found." << endl; @@ -150,9 +150,9 @@ int main(void) * of the objects in the file root direvtory. */ cout << "Unlinking..." << endl; - try { // attempt to unlink the dataset + try { // attempt to unlink the dataset file->unlink( "Data" ); - } + } catch( FileIException unlink_error ) { cout << " unlink failed." << endl; @@ -211,12 +211,12 @@ file_info(hid_t loc_id, const char *name, void *opdata) * Open the group using its name. */ group = H5Gopen(loc_id, name); - + /* * Display group name. */ cout << "Name : " << name << endl; - + H5Gclose(group); return 0; } diff --git a/c++/examples/readdata.cpp b/c++/examples/readdata.cpp index 7e5b195..5a1ec51 100644 --- a/c++/examples/readdata.cpp +++ b/c++/examples/readdata.cpp @@ -12,10 +12,10 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -// +// // This example reads hyperslab from the SDS.h5 file into -// two-dimensional plane of a three-dimensional array. Various -// information about the dataset in the SDS.h5 file is obtained. +// two-dimensional plane of a three-dimensional array. Various +// information about the dataset in the SDS.h5 file is obtained. // #include <string> @@ -54,7 +54,7 @@ int main (void) for (k = 0; k < NZ ; k++) data_out[j][i][k] = 0; } - } + } /* * Try block to detect exceptions raised by any of the calls inside it @@ -125,7 +125,7 @@ int main (void) (unsigned long)(dims_out[1]) << endl; /* - * Define hyperslab in the dataset; implicitly giving strike and + * Define hyperslab in the dataset; implicitly giving strike and * block NULL. */ hsize_t offset[2]; // hyperslab offset in the file @@ -143,10 +143,10 @@ int main (void) dimsm[0] = NX; dimsm[1] = NY; dimsm[2] = NZ ; - DataSpace memspace( RANK_OUT, dimsm ); + DataSpace memspace( RANK_OUT, dimsm ); /* - * Define memory hyperslab. + * Define memory hyperslab. */ hsize_t offset_out[3]; // hyperslab offset in memory hsize_t count_out[3]; // size of the hyperslab in memory @@ -159,7 +159,7 @@ int main (void) memspace.selectHyperslab( H5S_SELECT_SET, count_out, offset_out ); /* - * Read data from hyperslab in the file into the hyperslab in + * Read data from hyperslab in the file into the hyperslab in * memory and display the data. */ dataset.read( data_out, PredType::NATIVE_INT, memspace, dataspace ); @@ -174,7 +174,7 @@ int main (void) * 0 0 0 0 0 0 0 * 0 0 0 0 0 0 0 * 0 0 0 0 0 0 0 - * 3 4 5 6 0 0 0 + * 3 4 5 6 0 0 0 * 4 5 6 7 0 0 0 * 5 6 7 8 0 0 0 * 0 0 0 0 0 0 0 @@ -210,5 +210,5 @@ int main (void) } return 0; // successfully terminated -} +} diff --git a/c++/examples/writedata.cpp b/c++/examples/writedata.cpp index 0bed680..f50927d 100644 --- a/c++/examples/writedata.cpp +++ b/c++/examples/writedata.cpp @@ -12,15 +12,15 @@ * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ -/* +/* * This program shows how the select_hyperslab and select_elements * functions are used to write selected data from memory to the file. * Program takes 48 elements from the linear buffer and writes them into - * the matrix using 3x2 blocks, (4,3) stride and (2,4) count. - * Then four elements of the matrix are overwritten with the new values and + * the matrix using 3x2 blocks, (4,3) stride and (2,4) count. + * Then four elements of the matrix are overwritten with the new values and * file is closed. Program reopens the file and reads and displays the result. - */ - + */ + #include <string> #ifdef OLD_HEADER_FILENAME @@ -29,7 +29,7 @@ #include <iostream> #endif #include "H5Cpp.h" - + #ifndef H5_NO_NAMESPACE using namespace H5; #endif @@ -42,7 +42,7 @@ const int MSPACE2_RANK = 1; // Rank of the second dataset in memory const int MSPACE2_DIM = 4; // Dataset size in memory const int FSPACE_RANK = 2; // Dataset rank as it is stored in the file const int FSPACE_DIM1 = 8; // Dimension sizes of the dataset as it is... -const int FSPACE_DIM2 = 12; // ...stored in the file +const int FSPACE_DIM2 = 12; // ...stored in the file const int MSPACE_DIM1 = 8; // We will read dataset back from the file... const int MSPACE_DIM2 = 12; // ...to the dataset in memory with these ... // ...dataspace parameters @@ -90,12 +90,12 @@ int main (void) /* * Create dataset and write it into the file. */ - DataSet* dataset = new DataSet( + DataSet* dataset = new DataSet( file->createDataSet( DATASET_NAME, PredType::NATIVE_INT, fspace )); dataset->write( matrix, PredType::NATIVE_INT ); /* - * Select hyperslab for the dataset in the file, using 3x2 blocks, + * Select hyperslab for the dataset in the file, using 3x2 blocks, * (4,3) stride and (2,4) count starting at the position (0,1). */ hsize_t start[2]; // Start of hyperslab @@ -104,20 +104,20 @@ int main (void) hsize_t block[2]; // Block sizes start[0] = 0; start[1] = 1; stride[0] = 4; stride[1] = 3; - count[0] = 2; count[1] = 4; + count[0] = 2; count[1] = 4; block[0] = 3; block[1] = 2; fspace.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); /* * Create dataspace for the first dataset. */ - hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset - (in memory) */ + hsize_t dim1[] = {MSPACE1_DIM}; /* Dimension size of the first dataset + (in memory) */ DataSpace mspace1( MSPACE1_RANK, dim1 ); /* - * Select hyperslab. - * We will use 48 elements of the vector buffer starting at the + * Select hyperslab. + * We will use 48 elements of the vector buffer starting at the * second element. Selected elements are 1 2 3 . . . 48 */ start[0] = 1; @@ -125,12 +125,12 @@ int main (void) count[0] = 48; block[0] = 1; mspace1.selectHyperslab( H5S_SELECT_SET, count, start, stride, block); - + /* * Write selection from the vector buffer to the dataset in the file. * - * File dataset should look like this: - * 0 1 2 0 3 4 0 5 6 0 7 8 + * File dataset should look like this: + * 0 1 2 0 3 4 0 5 6 0 7 8 * 0 9 10 0 11 12 0 13 14 0 15 16 * 0 17 18 0 19 20 0 21 22 0 23 24 * 0 0 0 0 0 0 0 0 0 0 0 0 @@ -150,14 +150,14 @@ int main (void) * Create dataspace for the second dataset. */ hsize_t dim2[] = {MSPACE2_DIM}; /* Dimension size of the second dataset - (in memory */ + (in memory */ DataSpace mspace2( MSPACE2_RANK, dim2 ); /* * Select sequence of NPOINTS points in the file dataspace. */ - hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points - from the file dataspace */ + hsize_t coord[NPOINTS][FSPACE_RANK]; /* Array to store selected points + from the file dataspace */ coord[0][0] = 0; coord[0][1] = 0; coord[1][0] = 3; coord[1][1] = 3; coord[2][0] = 3; coord[2][1] = 5; @@ -169,11 +169,11 @@ int main (void) * Write new selection of points to the dataset. */ int values[] = {53, 59, 61, 67}; /* New values to be written */ - dataset->write( values, PredType::NATIVE_INT, mspace2, fspace ); + dataset->write( values, PredType::NATIVE_INT, mspace2, fspace ); /* - * File dataset should look like this: - * 53 1 2 0 3 4 0 5 6 0 7 8 + * File dataset should look like this: + * 53 1 2 0 3 4 0 5 6 0 7 8 * 0 9 10 0 11 12 0 13 14 0 15 16 * 0 17 18 0 19 20 0 21 22 0 23 24 * 0 0 0 59 0 61 0 0 0 0 0 0 @@ -181,7 +181,7 @@ int main (void) * 0 33 34 0 35 36 67 37 38 0 39 40 * 0 41 42 0 43 44 0 45 46 0 47 48 * 0 0 0 0 0 0 0 0 0 0 0 0 - * + * */ /* |