/* * Copyright (C) 1997 NCSA * All rights reserved. * * 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 #include #include #ifndef HAVE_FUNCTION #define __FUNCTION__ "" #endif #define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__); #define TEST_SMALL 0x0001 #define TEST_MEDIUM 0x0002 #define VARIABLE_SRC 0 #define VARIABLE_DST 1 #define VARIABLE_BOTH 2 /*------------------------------------------------------------------------- * Function: init_full * * Purpose: Initialize full array. * * Return: void * * Programmer: Robb Matzke * Friday, October 10, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static uintn init_full (uint8 *array, size_t nx, size_t ny, size_t nz) { int i, j, k; uint8 acc=128; uintn total=0; for (i=0; i1) { printf ("i=%d:\n", i); } else { printf ("%03d:", i); } for (j=0; j1) printf ("%03d:", 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 *array; array = H5MM_xcalloc (nx*ny*nz, sizeof(uint8)); 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 *dst=NULL; /*destination array */ size_t hs_size[3]; /*hyperslab size */ size_t dst_size[3]; /*destination total size */ size_t dst_offset[3]; /*offset of hyperslab in dest */ uintn ref_value; /*reference value */ uintn acc; /*accumulator */ int i, j, k, dx, dy, dz, u, v, w; /*counters */ int ndims; /*hyperslab dimensionality */ char dim[64],s[256]; /*temp string */ uintn 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 = H5MM_xcalloc (nx*ny*nz, 1); init_full (dst, nx, ny, nz); for (i=0; i