From 73a495e7ac5af18c3ad695da8eb2ead79c1a218c Mon Sep 17 00:00:00 2001 From: Leon Arber Date: Thu, 11 Nov 2004 21:37:53 -0500 Subject: [svn-r9523] Purpose: Added data transform example Description: Added example code for the data dtransform Solution: This code both illustrates how data transform works and shows how to use it. Examples of data transform on read, write, and both at the same time. Also shows usage of H5Pget_data_transform Platforms tested: eirene + copper Misc. update: --- examples/Makefile.in | 9 +++ examples/h5_dtransform.c | 185 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 194 insertions(+) create mode 100644 examples/h5_dtransform.c diff --git a/examples/Makefile.in b/examples/Makefile.in index 8895cb4..33ff82e 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -156,4 +156,13 @@ ph5example: $(srcdir)/ph5example.c $(H5CC_PP) $(CPPFLAGS) -o $@ $(srcdir)/$@.c; \ fi +h5_dtransform: $(srcdir)/h5_dtransform.c + @if test "X$(PARALLEL)" = "Xno"; then \ + echo $(H5CC) $(CPPFLAGS) -o $@ $(srcdir)/$@.c; \ + $(H5CC) $(CPPFLAGS) -o $@ $(srcdir)/$@.c; \ + else \ + echo $(H5CC_PP) $(CPPFLAGS) -o $@ $(srcdir)/$@.c; \ + $(H5CC_PP) $(CPPFLAGS) -o $@ $(srcdir)/$@.c; \ + fi + @CONCLUDE@ diff --git a/examples/h5_dtransform.c b/examples/h5_dtransform.c new file mode 100644 index 0000000..d013ecf --- /dev/null +++ b/examples/h5_dtransform.c @@ -0,0 +1,185 @@ + +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdf.ncsa.uiuc.edu/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from hdfhelp@ncsa.uiuc.edu. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This example demonstrates how the data transform features of + * HDF5 works. + * + * (1) + * The test first writes out data, with no data transform set. + * Then, the test reads back this data with a data transform applied. + * + * (2) + * Then, the test writes a new set of data, with a data transform set. + * Then, the test reads this new set of data, without a data set. + * + * (3) + * Lastly, the test reads the previous set of data (that was written out + * with a data transform) with a data transform set for the read. + * + * (4) + * Get the transform from the property using H5Pget_data_transform. + */ + +#include "hdf5.h" + +#define ROWS 12 +#define COLS 18 + +const float windchillF[ROWS][COLS] = + { {36.0, 31.0, 25.0, 19.0, 13.0, 7.0, 1.0, -5.0, -11.0, -16.0, -22.0, -28.0, -34.0, -40.0, -46.0, -52.0, -57.0, -63.0 }, + {34.0, 27.0, 21.0, 15.0, 9.0, 3.0, -4.0, -10.0, -16.0, -22.0, -28.0, -35.0, -41.0, -47.0, -53.0, -59.0, -66.0, -72.0 } , + {32.0, 25.0, 19.0, 13.0, 6.0, 0.0, -7.0, -13.0, -19.0, -26.0, -32.0, -39.0, -45.0, -51.0, -58.0, -64.0, -71.0, -77.0 }, + {30.0, 24.0, 17.0, 11.0, 4.0, -2.0, -9.0, -15.0, -22.0, -29.0, -35.0, -42.0, -48.0, -55.0, -61.0, -68.0, -74.0, -81.0 }, + {29.0, 23.0, 16.0, 9.0, 3.0, -4.0, -11.0, -17.0, -24.0, -31.0, -37.0, -44.0, -51.0, -58.0, -64.0, -71.0, -78.0, -84.0 }, + {28.0, 22.0, 15.0, 8.0, 1.0, -5.0, -12.0, -19.0, -26.0, -33.0, -39.0, -46.0, -53.0, -60.0, -67.0, -73.0, -80.0, -87.0 }, + {28.0, 21.0, 14.0, 7.0, 0.0, -7.0, -14.0, -21.0, -27.0, -34.0, -41.0, -48.0, -55.0, -62.0, -69.0, -76.0, -82.0, -89.0 }, + {27.0, 20.0, 13.0, 6.0, -1.0, -8.0, -15.0, -22.0, -29.0, -36.0, -43.0, -50.0, -57.0, -64.0, -71.0, -78.0, -84.0, -91.0 }, + {26.0, 19.0, 12.0, 5.0, -2.0, -9.0, -16.0, -23.0, -30.0, -37.0, -44.0, -51.0, -58.0, -65.0, -72.0, -79.0, -86.0, -93.0 }, + {26.0, 19.0, 12.0, 4.0, -3.0, -10.0, -17.0, -24.0, -31.0, -38.0, -45.0, -52.0, -60.0, -67.0, -74.0, -81.0, -88.0, -95.0}, + {25.0, 18.0, 11.0, 4.0, -3.0, -11.0, -18.0, -25.0, -32.0, -39.0, -46.0, -54.0, -61.0, -68.0, -75.0, -82.0, -89.0, -97.0}, + {25.0, 17.0, 10.0, 3.0, -4.0, -11.0, -19.0, -26.0, -33.0, -40.0, -48.0, -55.0, -62.0, -69.0, -76.0, -84.0, -91.0, -98.0} + }; + +#define PRINT(array) \ +{ \ + for(i=0; i