aboutsummaryrefslogtreecommitdiff
path: root/src/DumpVar.c
diff options
context:
space:
mode:
authortradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2001-06-12 22:39:17 +0000
committertradke <tradke@7842ec3a-9562-4be5-9c5b-06ba18f2b668>2001-06-12 22:39:17 +0000
commitbb8a2a2e3aacbcf0d2bf515c3db180c763ff3690 (patch)
treebc11b5555638a1160d2b4aa548a652261d144610 /src/DumpVar.c
parent55fbce955242ab0381d3ccee78f6b35e569c1ae3 (diff)
Support I/O for all the fixed-sized CCTK datatypes also.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOHDF5Util/trunk@33 7842ec3a-9562-4be5-9c5b-06ba18f2b668
Diffstat (limited to 'src/DumpVar.c')
-rw-r--r--src/DumpVar.c76
1 files changed, 37 insertions, 39 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c
index 4cc6b00..7feb035 100644
--- a/src/DumpVar.c
+++ b/src/DumpVar.c
@@ -21,7 +21,7 @@
/* the rcs ID and its dummy function to use it */
-static const char *rcsid = "$Id$";
+static const char *rcsid = "$Header$";
CCTK_FILEVERSION(BetaThorns_IOHDF5Util_DumpVar_c)
/* #define DEBUG_ME 1 */
@@ -146,7 +146,7 @@ int IOHDF5Util_DumpVar (cGH *GH,
hid_t file,
int check_exisiting_objects)
{
- int gtype;
+ int vtype, gtype;
pGH *pughGH;
ioHDF5UtilGH *myGH;
ioGH *ioUtilGH;
@@ -159,49 +159,43 @@ int IOHDF5Util_DumpVar (cGH *GH,
ioUtilGH = (ioGH *) CCTK_GHExtension (GH, "IO");
myGH = (ioHDF5UtilGH *) CCTK_GHExtension (GH, "IOHDF5Util");
- switch (CCTK_VarTypeI (vindex))
+ vtype = CCTK_VarTypeI (vindex);
+ /* downgrade the output precision if requested */
+ if (ioUtilGH->out_single)
{
- case CCTK_VARIABLE_CHAR:
- info.iohdf5_type = IOHDF5_CHAR;
- info.element_size = sizeof (CCTK_CHAR);
-#ifdef CCTK_MPI
- info.mpi_type = PUGH_MPI_CHAR;
+ /* Do we only want to downgrade generic CCTK types ? */
+#ifdef CCTK_REAL4
+ if (vtype == CCTK_VARIABLE_REAL)
+ {
+ vtype = CCTK_VARIABLE_REAL4;
+ }
+ else if (vtype == CCTK_VARIABLE_COMPLEX)
+ {
+ vtype = CCTK_VARIABLE_COMPLEX8;
+ }
#endif
- break;
-
- case CCTK_VARIABLE_INT:
- info.iohdf5_type = IOHDF5_INT;
- info.element_size = sizeof (CCTK_INT);
-#ifdef CCTK_MPI
- info.mpi_type = PUGH_MPI_INT;
+#ifdef CCTK_INT4
+ if (vtype == CCTK_VARIABLE_INT)
+ {
+ vtype = CCTK_VARIABLE_INT4;
+ }
#endif
- break;
-
- case CCTK_VARIABLE_REAL:
- info.iohdf5_type = ioUtilGH->out_single ? IOHDF5_REAL4 : IOHDF5_REAL;
- info.element_size = ioUtilGH->out_single ?
- sizeof (CCTK_REAL4) : sizeof (CCTK_REAL);
+ }
+ info.element_size = CCTK_VarTypeSize (vtype);
#ifdef CCTK_MPI
- info.mpi_type = ioUtilGH->out_single ? PUGH_MPI_REAL4 : PUGH_MPI_REAL;
+ info.mpi_type = PUGH_MPIDataType (pughGH, vtype);
#endif
- break;
+ info.iohdf5_type = IOHDF5Util_DataType (myGH, vtype);
- case CCTK_VARIABLE_COMPLEX:
- info.iohdf5_type = ioUtilGH->out_single ? myGH->IOHDF5_COMPLEX8 :
- myGH->IOHDF5_COMPLEX;
- info.element_size = ioUtilGH->out_single ?
- sizeof (CCTK_COMPLEX8) : sizeof (CCTK_COMPLEX);
+ if (info.element_size <= 0 ||
#ifdef CCTK_MPI
- info.mpi_type = ioUtilGH->out_single ? pughGH->PUGH_mpi_complex8 :
- pughGH->PUGH_mpi_complex;
+ info.mpi_type == MPI_DATATYPE_NULL ||
#endif
- break;
-
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported variable datatype '%s'",
- CCTK_VarTypeName (CCTK_VarTypeI (vindex)));
- return (-1);
+ info.iohdf5_type < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Unsupported variable type %d", vtype);
+ return (-1);
}
/* now branch to the appropriate dump routine */
@@ -560,11 +554,14 @@ static int IOHDF5Util_getDumpData (cGH *GH,
cctk_output_type = CCTK_VarTypeI (vindex);
if (ioUtilGH->out_single)
{
+#ifdef CCTK_INT4
if (cctk_output_type == CCTK_VARIABLE_INT)
{
cctk_output_type = CCTK_VARIABLE_INT4;
}
- else if (cctk_output_type == CCTK_VARIABLE_REAL)
+#endif
+#ifdef CCTK_REAL4
+ if (cctk_output_type == CCTK_VARIABLE_REAL)
{
cctk_output_type = CCTK_VARIABLE_REAL4;
}
@@ -572,6 +569,7 @@ static int IOHDF5Util_getDumpData (cGH *GH,
{
cctk_output_type = CCTK_VARIABLE_COMPLEX8;
}
+#endif
}
/* FIXME */
@@ -601,7 +599,7 @@ static int IOHDF5Util_getDumpData (cGH *GH,
if (NewHyperslab_GetLocalHyperslab (GH, vindex, timelevel, request->sdim,
cctk_output_type, NULL, request->origin,
request->direction, request->length,
- request->downsample, outme,
+ request->downsample, 1, outme, free_outme,
hsizes, hsizes_global, hsizes_offset) < 0)
{
fullname = CCTK_FullName (vindex);