aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-02-19 12:26:01 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-02-19 12:26:01 +0000
commitc7f8806fd524cc75fd6af99e5c4ea699105e10ee (patch)
tree8c018a5ab21d4626e404420b0f6f41e8a1c043ca /src
parent63b6f2c686382d4f5455c2f84d6aca0841bfd6f3 (diff)
Reflecting data with a given stencil width.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@96 4825ed28-b72c-4eae-9704-e50c059e567d
Diffstat (limited to 'src')
-rw-r--r--src/util/hdf5_bitant_to_fullmode.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/util/hdf5_bitant_to_fullmode.c b/src/util/hdf5_bitant_to_fullmode.c
index c887215..12abb1c 100644
--- a/src/util/hdf5_bitant_to_fullmode.c
+++ b/src/util/hdf5_bitant_to_fullmode.c
@@ -28,6 +28,9 @@ CCTK_FILEVERSION(AlphaThorns_IOHDF5_hdf5_bitant_to_fullmode_c)
/* uncomment the following to get some debugging output */
/* #define IOHDF5_DEBUG 1 */
+/* default stencil width if no '-stencil' option was given */
+#define STENCIL 2
+
/* macro to do an HDF5 call, check its return code, and print a warning
in case of an error */
#define CHECK_ERROR(hdf5_call) \
@@ -56,7 +59,7 @@ CCTK_FILEVERSION(AlphaThorns_IOHDF5_hdf5_bitant_to_fullmode_c)
a single user-supplied argument */
static char *pathname = NULL; /* pathname of the current object */
static unsigned int nerrors = 0; /* global error counter */
-static int flipsign = 0; /* flip sign of reflected elements */
+static int stencil = STENCIL; /* stencil width for reflection */
/*****************************************************************************/
/* local function prototypes */
@@ -98,11 +101,10 @@ int main (int argc, char *argv[])
hid_t infile, outfile;
- /* check for the '-flipsign' flag */
- flipsign = 0;
- if (argc > 1 && strcmp (argv[1], "-flipsign") == 0)
+ /* check for the '-stencil' option */
+ if (argc > 1 && strncmp (argv[1], "-stencil=", 9) == 0)
{
- flipsign = 1;
+ stencil = atoi (argv[1] + 9);
for (i = 2; i < argc; i++)
{
argv[i-1] = argv[i];
@@ -113,8 +115,8 @@ int main (int argc, char *argv[])
/* give some help if called with incorrect number of parameters */
if (argc != 3)
{
- fprintf (stderr, "Usage: %s [-flipsign] <bitant_infile> <fullmode_outfile>"
- "\n", argv[0]);
+ fprintf (stderr, "Usage: %s [-stencil=<N>] <bitant_infile> "
+ "<fullmode_outfile>\n", argv[0]);
fprintf (stderr, " eg, %s alp.h5 alp_fullmode.h5\n\n", argv[0]);
return (0);
}
@@ -141,7 +143,8 @@ int main (int argc, char *argv[])
printf ("\n ------------------------------------------\n"
" Cactus 4 HDF5 bitant-to-fullmode Converter\n"
- " ------------------------------------------\n");
+ " ------------------------------------------\n"
+ " Using stencil width of %d for reflection...\n", stencil);
/* do the copying by iterating over all objects */
pathname = "";
@@ -253,8 +256,8 @@ static herr_t CopyObject (hid_t from,
printf (" reflecting dataset '%s'\n", pathname);
CHECK_ERROR (H5Sget_simple_extent_dims (dataspace_from, dims, NULL));
/* save the bitant zmax and compute the fullgrid zmax */
- dims[3] = dims[0];
- dims[0] += dims[0] - 1;
+ dims[3] = dims[0] - stencil;
+ dims[0] = 2 * dims[3];
CHECK_ERROR (dataspace_to = H5Screate_simple (3, dims, NULL));
}
else
@@ -275,7 +278,7 @@ static herr_t CopyObject (hid_t from,
if (is_simple && ndims == 3)
{
xyplane_size = dims[1] * dims[2] * datatypesize;
- offset = (dims[3] - 1) * xyplane_size;
+ offset = (dims[3] - stencil) * xyplane_size;
objectsize += offset;
}
else
@@ -288,13 +291,14 @@ static herr_t CopyObject (hid_t from,
if (is_simple && ndims == 3)
{
/* copy the +z xy planes into the -z xy planes */
- for (i = 2; i < (int) dims[3]; i++)
+ for (i = stencil + 1; i <= (int) dims[3]; i++)
{
- memcpy (data + offset - (i-1)*xyplane_size,
- data + offset + i*xyplane_size,
+ memcpy (data + offset - (i-stencil)*xyplane_size,
+ data + offset + (i+stencil-1)*xyplane_size,
xyplane_size);
}
}
+#if 0
/* flip the sign of the reflected elements */
if (flipsign)
{
@@ -311,6 +315,7 @@ static herr_t CopyObject (hid_t from,
"datatype 'native double'\n");
}
}
+#endif
CHECK_ERROR (H5Dwrite (to, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT,data));
free (data);
}