/* * Creating and closing a dataset. */ #include "hdf5.h" #include "stdio.h" #define FILENAME "ublock.h5" int main() { hid_t file_id, dataset_id, dataspace_id, fcpl; /* identifiers */ hsize_t dims[2]; char ub[512]; herr_t status; int i,j; FILE *fp; int dset_data[4][6]; for (i = 0; i < 4; i++) for (j = 0; j < 6; j++) dset_data[i][j] = i * 6 + j + 1; fcpl = H5Pcreate (H5P_FILE_CREATE); status = H5Pset_userblock(fcpl, 512); file_id = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); /* Create the data space for the dataset. */ dims[0] = 4; dims[1] = 6; dataspace_id = H5Screate_simple(2, dims, NULL); /* Create the dataset. */ dataset_id = H5Dcreate(file_id, "/dset", H5T_STD_I32BE, dataspace_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); status = H5Dwrite(dataset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, dset_data); status = H5Pclose(fcpl); /* End access to the dataset and release resources used by it. */ status = H5Dclose(dataset_id); /* Terminate access to the data space. */ status = H5Sclose(dataspace_id); /* Close the file. */ /* status = H5Fclose(file_id); */ ub[0]='A'; for (i=1; i<512; i++) ub[i] = ub[0]; fp = fopen (FILENAME, "r+"); fwrite (ub, 1, 512, fp); fclose (fp); status = H5Fclose(file_id); printf ("H5Fclose returns: %i\n", status); }