aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-02-27 23:15:25 +0000
committertradke <tradke@4825ed28-b72c-4eae-9704-e50c059e567d>2002-02-27 23:15:25 +0000
commit354eecccc7b74478c8ebcc69e0bb7f686a934a0b (patch)
tree99db4a4b3b7702a9aae720f8b3d550d008743f8e
parent2a18c90c16bcca6f432db269f9e575a37e82c7b2 (diff)
Bugfix for sign flipping.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5/trunk@104 4825ed28-b72c-4eae-9704-e50c059e567d
-rw-r--r--src/util/hdf5_bitant_to_fullmode.c49
1 files changed, 35 insertions, 14 deletions
diff --git a/src/util/hdf5_bitant_to_fullmode.c b/src/util/hdf5_bitant_to_fullmode.c
index 12abb1c..8fd18d5 100644
--- a/src/util/hdf5_bitant_to_fullmode.c
+++ b/src/util/hdf5_bitant_to_fullmode.c
@@ -60,6 +60,7 @@ CCTK_FILEVERSION(AlphaThorns_IOHDF5_hdf5_bitant_to_fullmode_c)
static char *pathname = NULL; /* pathname of the current object */
static unsigned int nerrors = 0; /* global error counter */
static int stencil = STENCIL; /* stencil width for reflection */
+static int flipsign = 0; /* flag to flip the sign of reflected data */
/*****************************************************************************/
/* local function prototypes */
@@ -97,25 +98,40 @@ static void FixBoundingBox (hid_t object);
@@*/
int main (int argc, char *argv[])
{
- int i;
+ int i, j;
hid_t infile, outfile;
- /* check for the '-stencil' option */
- if (argc > 1 && strncmp (argv[1], "-stencil=", 9) == 0)
+ /* check for the options */
+ for (i = 1; i < argc; i++)
{
- stencil = atoi (argv[1] + 9);
- for (i = 2; i < argc; i++)
+ if (argv[i][0] == '-')
{
- argv[i-1] = argv[i];
+ if (strncmp (argv[i], "-stencil=", 9) == 0)
+ {
+ stencil = atoi (argv[i] + 9);
+ }
+ else if (strcmp (argv[i], "-flipsign") == 0)
+ {
+ flipsign = 1;
+ }
+ else
+ {
+ fprintf (stderr, "WARNING: unknown option '%s'\n", argv[i]);
+ }
+
+ for (j = i + 1; j < argc; j++)
+ {
+ argv[j-1] = argv[j];
+ }
+ argc--;
}
- argc--;
}
/* give some help if called with incorrect number of parameters */
if (argc != 3)
{
- fprintf (stderr, "Usage: %s [-stencil=<N>] <bitant_infile> "
+ fprintf (stderr, "Usage: %s [-stencil=<N>] [-flipsign] <bitant_infile> "
"<fullmode_outfile>\n", argv[0]);
fprintf (stderr, " eg, %s alp.h5 alp_fullmode.h5\n\n", argv[0]);
return (0);
@@ -248,6 +264,11 @@ static herr_t CopyObject (hid_t from,
{
CHECK_ERROR (from = H5Dopen (from, objectname));
CHECK_ERROR (datatype = H5Dget_type (from));
+ if (H5Tget_class (datatype) == H5T_FLOAT)
+ {
+ CHECK_ERROR (H5Tclose (datatype));
+ CHECK_ERROR (datatype = H5Tcopy (H5T_NATIVE_FLOAT));
+ }
CHECK_ERROR (dataspace_from = H5Dget_space (from));
CHECK_ERROR (is_simple = H5Sis_simple (dataspace_from));
CHECK_ERROR (ndims = H5Sget_simple_extent_ndims (dataspace_from));
@@ -298,24 +319,24 @@ static herr_t CopyObject (hid_t from,
xyplane_size);
}
}
-#if 0
+
/* flip the sign of the reflected elements */
if (flipsign)
{
- if (H5Tequal (datatype, H5T_NATIVE_DOUBLE) > 0)
+ if (H5Tget_class (datatype) == H5T_FLOAT)
{
- for (i = offset/sizeof (double) - 1; i >= 0; i--)
+ printf (" negating reflected data\n");
+ for (i = offset/sizeof (float) - 1; i >= 0; i--)
{
- ((double *) data)[i] = -((double *) data)[i];
+ ((float *) data)[i] = -((float *) data)[i];
}
}
else
{
fprintf (stderr, "Warning: can only flip sign for datasets of "
- "datatype 'native double'\n");
+ "floating-point datatype\n");
}
}
-#endif
CHECK_ERROR (H5Dwrite (to, datatype, H5S_ALL, H5S_ALL, H5P_DEFAULT,data));
free (data);
}