From ec7184bf2d37ac79e60ee85db0864841927e7605 Mon Sep 17 00:00:00 2001 From: Marc Howison Date: Thu, 11 Feb 2010 17:42:18 +0000 Subject: [PATCH] fixed missing test/read.c --- .gitattributes | 1 + test/read.c | 513 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 514 insertions(+) create mode 100644 test/read.c diff --git a/.gitattributes b/.gitattributes index aa18bef..e34208e 100644 --- a/.gitattributes +++ b/.gitattributes @@ -75,6 +75,7 @@ test/H5testF.f -text test/H5testFpar.F90 -text test/Makefile.am -text test/params.h -text +test/read.c -text test/test.c -text test/testframe.c -text test/testframe.h -text diff --git a/test/read.c b/test/read.c new file mode 100644 index 0000000..aaf0d96 --- /dev/null +++ b/test/read.c @@ -0,0 +1,513 @@ +#include + +#include "testframe.h" +#include "params.h" + +static void +test_read_file_attribs(H5PartFile *file, int position) +{ + h5part_int64_t status; + char name[ATTR_NAME_SIZE]; + + char str[ATTR_NAME_SIZE]; + h5part_int32_t i32; + h5part_int64_t i64; + h5part_float32_t f32; + h5part_float64_t f64; + + TEST("Reading file attributes"); + + i64 = H5PartGetNumFileAttribs(file); + VALUE(i64 % 5, 0, "file attribute count"); + + get_attr_name(name, "str", position); + status = H5PartReadFileAttrib(file, name, str); + RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib"); + SVALUE(str, ATTR_STR_VAL, "string attribute"); + + get_attr_name(name, "i32", position); + status = H5PartReadFileAttrib(file, name, &i32); + RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib"); + IVALUE(i32, ATTR_INT32_VAL, "int32 attribute"); + + get_attr_name(name, "i64", position); + status = H5PartReadFileAttrib(file, name, &i64); + RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib"); + IVALUE(i64, ATTR_INT64_VAL, "int64 attribute"); + + get_attr_name(name, "f32", position); + status = H5PartReadFileAttrib(file, name, &f32); + RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib"); + FVALUE(f32, ATTR_FLOAT_VAL, "float32 attribute"); + + get_attr_name(name, "f64", position); + status = H5PartReadFileAttrib(file, name, &f64); + RETURN(status, H5PART_SUCCESS, "H5PartReadFileAttrib"); + FVALUE(f64, ATTR_FLOAT_VAL, "float64 attribute"); +} + +static void +test_read_step_attribs(H5PartFile *file, int position) +{ + h5part_int64_t status; + char name[ATTR_NAME_SIZE]; + + char str[ATTR_NAME_SIZE]; + h5part_int32_t i32; + h5part_int64_t i64; + h5part_float32_t f32; + h5part_float64_t f64; + + TEST("Reading step attributes"); + + i64 = H5PartGetNumStepAttribs(file); + IVALUE(i64, 5, "step attribute count"); + + get_attr_name(name, "str", position); + status = H5PartReadStepAttrib(file, name, str); + RETURN(status, H5PART_SUCCESS, "H5PartReadStepAttrib"); + SVALUE(str, ATTR_STR_VAL, "string attribute"); + + get_attr_name(name, "i32", position); + status = H5PartReadStepAttrib(file, name, &i32); + RETURN(status, H5PART_SUCCESS, "H5PartReadStepAttrib"); + IVALUE(i32, ATTR_INT32_VAL, "int32 attribute"); + + get_attr_name(name, "i64", position); + status = H5PartReadStepAttrib(file, name, &i64); + RETURN(status, H5PART_SUCCESS, "H5PartReadStepAttrib"); + IVALUE(i64, ATTR_INT64_VAL, "int64 attribute"); + + get_attr_name(name, "f32", position); + status = H5PartReadStepAttrib(file, name, &f32); + RETURN(status, H5PART_SUCCESS, "H5PartReadStepAttrib"); + FVALUE(f32, ATTR_FLOAT_VAL, "float32 attribute"); + + get_attr_name(name, "f64", position); + status = H5PartReadStepAttrib(file, name, &f64); + RETURN(status, H5PART_SUCCESS, "H5PartReadStepAttrib"); + FVALUE(f64, ATTR_FLOAT_VAL, "float64 attribute"); +} + +static void +test_read_data64(H5PartFile *file, int nparticles, int step) +{ + int i,t; + int rank, nprocs; + h5part_int64_t status, val, start, end, type, size; + char name1[4]; + char name2[8]; + h5part_int64_t indices[8]; + + double *x,*y,*z; + double *px,*py,*pz; + h5part_int64_t *id; + + x=(double*)malloc(nparticles*sizeof(double)); + y=(double*)malloc(nparticles*sizeof(double)); + z=(double*)malloc(nparticles*sizeof(double)); + px=(double*)malloc(nparticles*sizeof(double)); + py=(double*)malloc(nparticles*sizeof(double)); + pz=(double*)malloc(nparticles*sizeof(double)); + id=(h5part_int64_t*)malloc(nparticles*sizeof(h5part_int64_t)); + + TEST("Verifying dataset info"); + +#if PARALLEL_IO + MPI_Comm_rank(MPI_COMM_WORLD, &rank); + MPI_Comm_size(MPI_COMM_WORLD, &nprocs); +#else + nprocs = 1; + rank = 2; +#endif + + val = H5PartGetNumParticles(file); + IVALUE(val, nprocs*nparticles, "particle count"); + + val = H5PartGetNumDatasets(file); + IVALUE(val, 7, "dataset count"); + + for (i=0; i<7; i++) { + status = H5PartGetDatasetName(file, i, name1, 2); + RETURN(status, H5PART_SUCCESS, "H5PartGetDatasetName"); + + status = H5PartGetDatasetInfo( + file, i, name2, 4, &type, &size); + RETURN(status, H5PART_SUCCESS, "H5PartGetDatasetInfo"); + CVALUE(name1[0], name2[0], "dataset name"); + + status = H5PartGetDatasetName(file, i, name1, 4); + RETURN(status, H5PART_SUCCESS, "H5PartGetDatasetName"); + CVALUE(name1[1], name2[1], "dataset name"); + + IVALUE(size, nprocs*nparticles, "dataset size"); + if (name1[0] == 'i') IVALUE(type, H5PART_INT64, "dataset type"); + else IVALUE(type, H5PART_FLOAT64, "dataset type"); + } + +#if PARALLEL_IO + TEST("Setting throttle"); + status = H5PartSetThrottle(file, 3); + RETURN(status, H5PART_SUCCESS, "H5PartSetThrottle"); +#endif + + TEST("Reading 64-bit data"); + + for (t=step; t