diff options
Diffstat (limited to 'tools/h5repack/testh5repack_dset.c')
-rw-r--r-- | tools/h5repack/testh5repack_dset.c | 88 |
1 files changed, 44 insertions, 44 deletions
diff --git a/tools/h5repack/testh5repack_dset.c b/tools/h5repack/testh5repack_dset.c index 8781ae7..862257a 100644 --- a/tools/h5repack/testh5repack_dset.c +++ b/tools/h5repack/testh5repack_dset.c @@ -22,7 +22,7 @@ static void make_dset_reg_ref(hid_t loc_id); /*------------------------------------------------------------------------- * Function: write_dset_in * - * Purpose: write datasets in LOC_ID + * Purpose: write datasets in LOC_ID * * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu * @@ -31,28 +31,28 @@ static void make_dset_reg_ref(hid_t loc_id); *------------------------------------------------------------------------- */ - -void write_dset_in(hid_t loc_id, + +void write_dset_in(hid_t loc_id, const char* dset_name, /* for saving reference to dataset*/ hid_t file_id, int make_diffs /* flag to modify data buffers */) { /* Compound datatype */ - typedef struct s_t + typedef struct s_t { char a; double b; } s_t; - typedef enum + typedef enum { RED, GREEN } e_t; hid_t dset_id; - hid_t space_id; - hid_t type_id; + hid_t space_id; + hid_t type_id; hid_t plist_id; herr_t status; int val, i, j, k, n; @@ -100,22 +100,22 @@ void write_dset_in(hid_t loc_id, /*------------------------------------------------------------------------- - * 1D + * 1D *------------------------------------------------------------------------- */ - + /*------------------------------------------------------------------------- * H5T_STRING *------------------------------------------------------------------------- */ - + if (make_diffs) { for (i=0; i<2; i++) for (j=0; j<2; j++) { - buf1[i][j]='z'; + buf1[i][j]='z'; } } @@ -172,7 +172,7 @@ void write_dset_in(hid_t loc_id, { for (i=0; i<2; i++) { - buf45[i]=GREEN; + buf45[i]=GREEN; } } @@ -181,7 +181,7 @@ void write_dset_in(hid_t loc_id, H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_dset(loc_id,1,dims,"compound",type_id,buf3); status = H5Tclose(type_id); - + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -211,7 +211,7 @@ void write_dset_in(hid_t loc_id, * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ buf5[0].len = 1; @@ -250,7 +250,7 @@ void write_dset_in(hid_t loc_id, for (i=0; i<2; i++) for (j=0; j<3; j++) { - buf6[i][j]=0; + buf6[i][j]=0; } } @@ -267,8 +267,8 @@ void write_dset_in(hid_t loc_id, { for (i=0; i<2; i++) { - buf7[i]=0; - buf8[i]=0; + buf7[i]=0; + buf8[i]=0; } } @@ -277,7 +277,7 @@ void write_dset_in(hid_t loc_id, /*------------------------------------------------------------------------- - * 2D + * 2D *------------------------------------------------------------------------- */ @@ -302,7 +302,7 @@ void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf22,0,sizeof buf22); @@ -336,7 +336,7 @@ void write_dset_in(hid_t loc_id, H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_dset(loc_id,2,dims2,"compound2D",type_id,buf32); status = H5Tclose(type_id); - + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -380,7 +380,7 @@ void write_dset_in(hid_t loc_id, else ((int *)buf52[i][j].p)[l] = n++; } } - + space_id = H5Screate_simple(2,dims2,NULL); type_id = H5Tvlen_create(H5T_NATIVE_INT); dset_id = H5Dcreate(loc_id,"vlen2D",type_id,space_id,H5P_DEFAULT); @@ -412,7 +412,7 @@ void write_dset_in(hid_t loc_id, *------------------------------------------------------------------------- */ - + if (make_diffs) { memset(buf72,0,sizeof buf72); @@ -435,9 +435,9 @@ void write_dset_in(hid_t loc_id, write_dset(loc_id,2,dims2,"float2D",H5T_NATIVE_FLOAT,buf82); - + /*------------------------------------------------------------------------- - * 3D + * 3D *------------------------------------------------------------------------- */ @@ -513,7 +513,7 @@ void write_dset_in(hid_t loc_id, H5Tinsert(type_id, "b", HOFFSET(s_t, b), H5T_NATIVE_DOUBLE); write_dset(loc_id,3,dims3,"compound3D",type_id,buf33); status = H5Tclose(type_id); - + /*------------------------------------------------------------------------- * H5T_REFERENCE *------------------------------------------------------------------------- @@ -545,7 +545,7 @@ void write_dset_in(hid_t loc_id, * H5T_VLEN *------------------------------------------------------------------------- */ - + /* Allocate and initialize VL dataset to write */ n=0; for (i = 0; i < 4; i++) { @@ -560,7 +560,7 @@ void write_dset_in(hid_t loc_id, } } } - + space_id = H5Screate_simple(3,dims3,NULL); type_id = H5Tvlen_create(H5T_NATIVE_INT); dset_id = H5Dcreate(loc_id,"vlen3D",type_id,space_id,H5P_DEFAULT); @@ -618,7 +618,7 @@ void write_dset_in(hid_t loc_id, /*------------------------------------------------------------------------- * Function: make_dset_reg_ref * - * Purpose: write dataset region references + * Purpose: write dataset region references * *------------------------------------------------------------------------- */ @@ -646,52 +646,52 @@ static void make_dset_reg_ref(hid_t loc_id) int *dwbuf; /* Buffer for writing numeric data to disk */ int i; /* counting variables */ herr_t ret; /* Generic return value */ - + /* Allocate write & read buffers */ wbuf=calloc(sizeof(hdset_reg_ref_t), SPACE1_DIM1); dwbuf=malloc(sizeof(int)*SPACE2_DIM1*SPACE2_DIM2); - + /* Create dataspace for datasets */ sid2 = H5Screate_simple(SPACE2_RANK, dims2, NULL); - + /* Create a dataset */ dset2=H5Dcreate(loc_id,"dsetreg",H5T_NATIVE_UCHAR,sid2,H5P_DEFAULT); - + for(i=0; i<SPACE2_DIM1*SPACE2_DIM2; i++) - dwbuf[i]=i*3; - + dwbuf[i]=i*3; + /* Write selection to disk */ ret=H5Dwrite(dset2,H5T_NATIVE_INT,H5S_ALL,H5S_ALL,H5P_DEFAULT,dwbuf); - + /* Close Dataset */ ret = H5Dclose(dset2); - + /* Create dataspace for the reference dataset */ sid1 = H5Screate_simple(SPACE1_RANK, dims1, NULL); - + /* Create a dataset */ dset1=H5Dcreate(loc_id,"refreg",H5T_STD_REF_DSETREG,sid1,H5P_DEFAULT); - + /* Create references */ - + /* Select 6x6 hyperslab for first reference */ start[0]=2; start[1]=2; stride[0]=1; stride[1]=1; count[0]=6; count[1]=6; block[0]=1; block[1]=1; ret = H5Sselect_hyperslab(sid2,H5S_SELECT_SET,start,stride,count,block); - + /* Store dataset region */ ret = H5Rcreate(&wbuf[0],loc_id,"dsetreg",H5R_DATASET_REGION,sid2); - + /* Write selection to disk */ ret=H5Dwrite(dset1,H5T_STD_REF_DSETREG,H5S_ALL,H5S_ALL,H5P_DEFAULT,wbuf); - + /* Close all objects */ ret = H5Sclose(sid1); ret = H5Dclose(dset1); ret = H5Sclose(sid2); - + free(wbuf); free(dwbuf); -} +} |