Created
July 30, 2014 04:59
-
-
Save smutch/e8bc11367d103d6b703c to your computer and use it in GitHub Desktop.
c: example read for a Meraxes grid
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <hdf5.h> | |
#include <hdf5_hl.h> | |
#include <math.h> | |
int main(int argc, char *argv[]) | |
{ | |
hsize_t dims[1]; | |
size_t type_size; | |
H5T_class_t class_id; | |
hid_t fd; | |
float *grid; | |
int dim; | |
int snapshot = 51; | |
char ds_name[] = {"delta_T"}; | |
char ds_path[128]; | |
printf("Reading grid...\n"); | |
fd = H5Fopen("/Users/smutch/data_temp/meraxes.hdf5", H5F_ACC_RDONLY, H5P_DEFAULT); | |
sprintf(ds_path, "Snap%03d/Grids/%s", snapshot, ds_name); | |
H5LTget_dataset_info(fd, ds_path, dims, &class_id, &type_size); | |
grid = malloc(sizeof(float) * dims[0]); | |
dim = (int)(cbrt((double)(dims[0]))); | |
H5LTread_dataset_float(fd, ds_path, grid); | |
H5Fclose(fd); | |
printf("...done\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment