/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Copyright by The HDF Group. * * 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://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * * access to either file, you may request a copy from help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* Programmer: Robb Matzke * Friday, October 10, 1997 * * Purpose: Hyperslab operations are rather complex, so this file * attempts to test them extensively so we can be relatively * sure they really work. We only test 1d, 2d, and 3d cases * because testing general dimensionalities would require us to * rewrite much of the hyperslab stuff. */ #include "h5test.h" #include "H5private.h" #include "H5Eprivate.h" #include "H5Vprivate.h" #define TEST_SMALL 0x0001 #define TEST_MEDIUM 0x0002 #define VARIABLE_SRC 0 #define VARIABLE_DST 1 #define VARIABLE_BOTH 2 #define ARRAY_FILL_SIZE 4 #define ARRAY_OFFSET_NDIMS 3 /*------------------------------------------------------------------------- * Function: init_full * * Purpose: Initialize full array. * * Return: void * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static unsigned init_full(uint8_t *array, size_t nx, size_t ny, size_t nz) { size_t i, j, k; uint8_t acc = 128; unsigned total = 0; for (i=0; i1) { printf("i=%lu:\n", (unsigned long)i); } else { printf("%03lu:", (unsigned long)i); } for (j=0; j1) printf("%03lu:", (unsigned long)j); for (k=0; k1) printf("\n"); } printf("\n"); } } /*------------------------------------------------------------------------- * Function: print_ref * * Purpose: Prints the reference value * * Return: Success: 0 * * Failure: * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static void print_ref(size_t nx, size_t ny, size_t nz) { uint8_t *array; array = HDcalloc(nx*ny*nz,sizeof(uint8_t)); printf("Reference array:\n"); init_full(array, nx, ny, nz); print_array(array, nx, ny, nz); } /*------------------------------------------------------------------------- * Function: test_fill * * Purpose: Tests the H5V_hyper_fill() function. * * Return: Success: SUCCEED * * Failure: FAIL * * Programmer: Robb Matzke * Saturday, October 11, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t test_fill(size_t nx, size_t ny, size_t nz, size_t di, size_t dj, size_t dk, size_t ddx, size_t ddy, size_t ddz) { uint8_t *dst = NULL; /*destination array */ hsize_t hs_size[3]; /*hyperslab size */ hsize_t dst_size[3]; /*destination total size */ hsize_t dst_offset[3]; /*offset of hyperslab in dest */ unsigned ref_value; /*reference value */ unsigned acc; /*accumulator */ size_t i, j, k, dx, dy, dz; /*counters */ size_t u, v, w; unsigned ndims; /*hyperslab dimensionality */ char dim[64], s[256]; /*temp string */ unsigned fill_value; /*fill value */ /* * Dimensionality. */ if (0 == nz) { if (0 == ny) { ndims = 1; ny = nz = 1; sprintf(dim, "%lu", (unsigned long) nx); } else { ndims = 2; nz = 1; sprintf(dim, "%lux%lu", (unsigned long) nx, (unsigned long) ny); } } else { ndims = 3; sprintf(dim, "%lux%lux%lu", (unsigned long) nx, (unsigned long) ny, (unsigned long) nz); } sprintf(s, "Testing hyperslab fill %-11s variable hyperslab", dim); printf("%-70s", s); fflush(stdout); /* Allocate array */ dst = HDcalloc((size_t)1, nx * ny * nz); init_full(dst, nx, ny, nz); for (i = 0; i < nx; i += di) { for (j = 0; j < ny; j += dj) { for (k = 0; k < nz; k += dk) { for (dx = 1; dx <= nx - i; dx += ddx) { for (dy = 1; dy <= ny - j; dy += ddy) { for (dz = 1; dz <= nz - k; dz += ddz) { /* Describe the hyperslab */ dst_size[0] = nx; dst_size[1] = ny; dst_size[2] = nz; dst_offset[0] = i; dst_offset[1] = j; dst_offset[2] = k; hs_size[0] = dx; hs_size[1] = dy; hs_size[2] = dz; for (fill_value=0; fill_value<256; fill_value+=64) { /* * Initialize the full array, then subtract the * original * fill values and add the new ones. */ ref_value = init_full(dst, nx, ny, nz); for (u=(size_t)dst_offset[0]; u