diff options
Diffstat (limited to 'examples')
-rw-r--r-- | examples/h5_vol_external_log_native.c | 192 |
1 files changed, 86 insertions, 106 deletions
diff --git a/examples/h5_vol_external_log_native.c b/examples/h5_vol_external_log_native.c index 945588a..a25be6d 100644 --- a/examples/h5_vol_external_log_native.c +++ b/examples/h5_vol_external_log_native.c @@ -142,125 +142,105 @@ visit_cb(hid_t oid, const char *name, } /* end h5_verify_cached_stabs_cb() */ int main(int argc, char **argv) { - const char file_name[]="large_dataset.h5"; + const char file_name[]="large_dataset.h5"; const char group_name[]="/Group"; const char dataset_name[]="Data"; char fullpath[500]; hid_t file_id; hid_t group_id; hid_t dataspaceId; - hid_t datasetId; - hid_t acc_tpl; - hid_t under_fapl; - hid_t vol_id, vol_id2; - hid_t int_id; - hid_t attr; - hid_t space; - const unsigned int nelem=60; - int *data; - unsigned int i; - hsize_t dims[1]; - ssize_t len; - char name[25]; - static hsize_t ds_size[2] = {10, 20}; - - under_fapl = H5Pcreate (H5P_FILE_ACCESS); - H5Pset_fapl_native(under_fapl); - assert(H5VLis_registered("native") == 1); - - vol_id = H5VLregister (&H5VL_log_g); - assert(vol_id > 0); - assert(H5VLis_registered("log") == 1); - - vol_id2 = H5VLget_driver_id("log"); - H5VLinitialize(vol_id2, H5P_DEFAULT); - H5VLclose(vol_id2); - - native_driver_id = H5VLget_driver_id("native"); - assert(native_driver_id > 0); - - acc_tpl = H5Pcreate (H5P_FILE_ACCESS); - H5Pset_vol(acc_tpl, vol_id, &under_fapl); - - file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); - len = H5VLget_driver_name(file_id, name, 25); - printf ("FILE VOL name = %s %d\n", name, len); - - group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - len = H5VLget_driver_name(group_id, name, 50); - printf ("GROUP VOL name = %s %d\n", name, len); - - int_id = H5Tcopy(H5T_NATIVE_INT); - H5Tcommit2(file_id, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf ("DT COMMIT name = %s %d\n", name, len); - H5Tclose(int_id); - - int_id = H5Topen2(file_id, "int", H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf ("DT OPEN name = %s %d\n", name, len); - H5Tclose(int_id); - - int_id = H5Oopen(file_id,"int",H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf ("DT OOPEN name = %s %d\n", name, len); - - len = H5Fget_name(file_id, name, 50); - printf("name = %d %s\n", len, name); - - data = malloc (sizeof(int)*nelem); - for(i=0;i<nelem;++i) - data[i]=i; - - dims [0] = 60; - dataspaceId = H5Screate_simple(1, dims, NULL); - space = H5Screate_simple (2, ds_size, ds_size); - - sprintf(fullpath,"%s/%s",group_name,dataset_name); - datasetId = H5Dcreate2(file_id,fullpath,H5T_NATIVE_INT,dataspaceId,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - H5Sclose(dataspaceId); - - len = H5VLget_driver_name(datasetId, name, 50); - printf ("DSET name = %s %d\n", name, len); - - H5Dwrite(datasetId, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - H5Dclose(datasetId); - - H5Ovisit2(file_id, H5_INDEX_NAME, H5_ITER_NATIVE, visit_cb, NULL, H5O_INFO_ALL); - - free (data); - H5Oclose(int_id); - H5Sclose (space); - H5Gclose(group_id); -#if 0 + hid_t datasetId; + hid_t acc_tpl; + hid_t under_fapl; + hid_t vol_id, vol_id2; + hid_t int_id; + hid_t attr; + hid_t space; + const unsigned int nelem=60; + int *data; + unsigned int i; + hsize_t dims[1]; + ssize_t len; + char name[25]; + static hsize_t ds_size[2] = {10, 20}; - attr = H5Acreate2(group_id, "attr1", int_id, space, H5P_DEFAULT, H5P_DEFAULT); - int_id = H5Aget_type(attr); - len = H5VLget_driver_name(int_id, name, 50); - printf ("DT OPEN name = %s %d\n", name, len); + under_fapl = H5Pcreate(H5P_FILE_ACCESS); + H5Pset_fapl_native(under_fapl); + assert(H5VLis_driver_registered("native") == 1); - H5Aclose (attr); + vol_id = H5VLregister_driver(&H5VL_log_g); + assert(vol_id > 0); + assert(H5VLis_driver_registered("log") == 1); - int_id = H5Oopen(file_id,"int",H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf ("DT OOPEN name = %s %d\n", name, len); - H5Oclose(int_id); + vol_id2 = H5VLget_driver_id("log"); + H5VLinitialize(vol_id2, H5P_DEFAULT); + H5VLclose(vol_id2); + native_driver_id = H5VLget_driver_id("native"); + assert(native_driver_id > 0); - H5Fclose(file_id); - file_id = H5Fopen(file_name, H5F_ACC_RDWR, H5P_DEFAULT);//acc_tpl); - H5Fflush(file_id, H5F_SCOPE_GLOBAL); -#endif + acc_tpl = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_vol(acc_tpl, vol_id, &under_fapl); + + file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + len = H5VLget_driver_name(file_id, name, 25); + printf ("FILE VOL name = %s %d\n", name, len); + + group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + len = H5VLget_driver_name(group_id, name, 50); + printf ("GROUP VOL name = %s %d\n", name, len); + + int_id = H5Tcopy(H5T_NATIVE_INT); + H5Tcommit2(file_id, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + len = H5VLget_driver_name(int_id, name, 50); + printf ("DT COMMIT name = %s %d\n", name, len); + H5Tclose(int_id); + + int_id = H5Topen2(file_id, "int", H5P_DEFAULT); + len = H5VLget_driver_name(int_id, name, 50); + printf ("DT OPEN name = %s %d\n", name, len); + H5Tclose(int_id); + + int_id = H5Oopen(file_id,"int",H5P_DEFAULT); + len = H5VLget_driver_name(int_id, name, 50); + printf ("DT OOPEN name = %s %d\n", name, len); - H5Fclose(file_id); - H5Pclose(acc_tpl); - H5Pclose(under_fapl); + len = H5Fget_name(file_id, name, 50); + printf("name = %d %s\n", len, name); - H5VLclose(native_driver_id); - H5VLterminate(vol_id, H5P_DEFAULT); - H5VLunregister (vol_id); - assert(H5VLis_registered("log") == 0); - return 0; + data = malloc (sizeof(int)*nelem); + for(i=0;i<nelem;++i) + data[i]=i; + + dims [0] = 60; + dataspaceId = H5Screate_simple(1, dims, NULL); + space = H5Screate_simple (2, ds_size, ds_size); + + sprintf(fullpath,"%s/%s",group_name,dataset_name); + datasetId = H5Dcreate2(file_id,fullpath,H5T_NATIVE_INT,dataspaceId,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); + H5Sclose(dataspaceId); + + len = H5VLget_driver_name(datasetId, name, 50); + printf ("DSET name = %s %d\n", name, len); + + H5Dwrite(datasetId, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); + H5Dclose(datasetId); + + H5Ovisit2(file_id, H5_INDEX_NAME, H5_ITER_NATIVE, visit_cb, NULL, H5O_INFO_ALL); + + free (data); + H5Oclose(int_id); + H5Sclose (space); + H5Gclose(group_id); + H5Fclose(file_id); + H5Pclose(acc_tpl); + H5Pclose(under_fapl); + + H5VLclose(native_driver_id); + H5VLterminate(vol_id, H5P_DEFAULT); + H5VLunregister_driver(vol_id); + assert(H5VLis_driver_registered("log") == 0); + return 0; } static herr_t H5VL_log_init(hid_t vipl_id) |