Files
src_old/test/h5b_write.c
T
Marc Howison 7ea00c38f8 Integrated H5Part regression test and fixed numerous errors that it discovered.
Finished integrating H5Block and the Fortran interface (untested).
Started adding an H5Block regression test with a few simple tests (all pass).
Added automatic detection of stripe information on lustre, and config option to compile against lustre API.
Moved buffers for H5Block ghost zone disolving out of the file handle and into the h5b_3d_set_view function.
Fixed bug with pointers in the H5Fed file data not being initialized to NULL.
2010-07-15 19:44:48 +00:00

132 lines
3.3 KiB
C

#include <stdlib.h>
#include "testframe.h"
#include "params.h"
static void
test_write_field_attribs(
h5_file_t *file,
const char *field_name,
int position)
{
h5_err_t status;
char name[ATTR_NAME_SIZE];
TEST("Writing field attributes");
get_attr_name(name, "str", position);
status = H5BlockWriteFieldAttribString(
file, field_name, name, ATTR_STR_VAL);
RETURN(status, H5_SUCCESS, "H5BlockWriteFieldAttribString");
get_attr_name(name, "i32", position);
h5_int32_t i32 = ATTR_INT32_VAL;
status = H5BlockWriteFieldAttribInt32(
file, field_name, name, &i32, 1);
RETURN(status, H5_SUCCESS, "H5BlockWriteFieldAttribInt32");
get_attr_name(name, "i64", position);
h5_int64_t i64 = ATTR_INT64_VAL;
status = H5BlockWriteFieldAttribInt64(
file, field_name, name, &i64, 1);
RETURN(status, H5_SUCCESS, "H5BlockWriteFieldAttribInt64");
get_attr_name(name, "f32", position);
h5_float32_t f32 = ATTR_FLOAT_VAL;
status = H5BlockWriteFieldAttribFloat32(
file, field_name, name, &f32, 1);
RETURN(status, H5_SUCCESS, "H5BlockWriteFieldAttribFloat32");
get_attr_name(name, "f64", position);
h5_float64_t f64 = ATTR_FLOAT_VAL;
status = H5BlockWriteFieldAttribFloat64(
file, field_name, name, &f64, 1);
RETURN(status, H5_SUCCESS, "H5BlockWriteFieldAttribFloat64");
}
static void
test_write_data64(h5_file_t *file, int step)
{
extern h5_size_t layout[6];
int i,t;
h5_int64_t status, val;
double *e;
double *ex,*ey,*ez;
h5_int64_t *id;
const size_t nelems =
(layout[1] - layout[0] + 1) *
(layout[3] - layout[2] + 1) *
(layout[5] - layout[4] + 1);
e=(double*)malloc(nelems*sizeof(double));
ex=(double*)malloc(nelems*sizeof(double));
ey=(double*)malloc(nelems*sizeof(double));
ez=(double*)malloc(nelems*sizeof(double));
id=(h5_int64_t*)malloc(nelems*sizeof(h5_int64_t));
#if PARALLEL_IO
TEST("Setting throttle");
status = H5SetThrottle(file, 2);
RETURN(status, H5_SUCCESS, "H5SetThrottle");
#endif
TEST("Writing 64-bit data");
for (t=step; t<step+NTIMESTEPS; t++)
{
for (i=0; i<nelems; i++)
{
e[i] = 0.0 + (double)(i+nelems*t);
ex[i] = 0.1 + (double)(i+nelems*t);
ey[i] = 0.2 + (double)(i+nelems*t);
ez[i] = 0.3 + (double)(i+nelems*t);
id[i] = i + nelems*t;
}
val = H5HasStep(file, t);
status = H5SetStep(file, t);
RETURN(status, H5_SUCCESS, "H5SetStep");
if (val == 0) test_write_field_attribs(file, "e", t);
status = H5Block3dSetView(file,
layout[0], layout[1],
layout[2], layout[3],
layout[4], layout[5]);
RETURN(status, H5_SUCCESS, "H5Block3dSetView");
status = H5Block3dWriteScalarFieldFloat64(file, "e", e);
RETURN(status, H5_SUCCESS, "H5Block3dWriteScalarFieldFloat64");
status = H5Block3dWriteVector3dFieldFloat64(file,
"E", ex, ey, ez);
RETURN(status, H5_SUCCESS,
"H5Block3dWriteVector3dFieldFloat64");
status = H5Block3dWriteScalarFieldInt64(file, "id", id);
RETURN(status, H5_SUCCESS, "H5Block3dWriteScalarFieldInt64");
}
}
void h5b_test_write1(void)
{
h5_file_t *file1;
h5_err_t status;
TEST("Opening file once, write-truncate");
file1 = H5OpenFile(FILENAME, H5_O_WRONLY, MPI_COMM_WORLD);
status = H5CheckFile(file1);
RETURN(status, H5_SUCCESS, "H5CheckFile");
test_write_data64(file1, 1);
status = H5CloseFile(file1);
RETURN(status, H5_SUCCESS, "H5CloseFile");
}