aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2001-06-12 22:45:13 +0000
committertradke <tradke@ebee0441-1374-4afa-a3b5-247f3ba15b9a>2001-06-12 22:45:13 +0000
commit754fe12ed0b10af5aa281193488a7641ef1de2a4 (patch)
treedf2d691e7782871c53481a23133f5387767a97c7 /src
parenta93c5ee313def56a89065efcce5745e8e7a84398 (diff)
Support I/O for all the fixed-sized CCTK datatypes also.
git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@204 ebee0441-1374-4afa-a3b5-247f3ba15b9a
Diffstat (limited to 'src')
-rw-r--r--src/DumpVar.c129
-rw-r--r--src/Output3D.c16
-rw-r--r--src/RestoreFile.c35
-rw-r--r--src/ioFlexGH.h35
4 files changed, 139 insertions, 76 deletions
diff --git a/src/DumpVar.c b/src/DumpVar.c
index 49fafb0..c172c41 100644
--- a/src/DumpVar.c
+++ b/src/DumpVar.c
@@ -113,58 +113,53 @@ static void IOFlexIO_procDump (IOFile iof, cGH *GH, int vindex, void *outme,
@@*/
void IOFlexIO_DumpVar (cGH *GH, int vindex, int timelevel, IOFile iof)
{
+ pGH *pughGH;
ioGH *ioUtilGH;
- int variable_type;
+ int vtype;
dumpInfo_t info;
- /* Get the handle for IOUtil extensions */
+ /* Get the handle for PUGH and IOUtil extensions */
ioUtilGH = (ioGH *) GH->extensions [CCTK_GHExtensionHandle ("IO")];
+ pughGH = (pGH *) GH->extensions [CCTK_GHExtensionHandle ("PUGH")];
- variable_type = CCTK_VarTypeI (vindex);
-
- switch (variable_type) {
- case CCTK_VARIABLE_REAL:
- info.flexio_type = ioUtilGH->out_single ? FLEXIO_REAL4 : FLEXIO_REAL;
- info.element_size = ioUtilGH->out_single ?
- sizeof (CCTK_REAL4) : sizeof (CCTK_REAL);
-#ifdef CCTK_MPI
- info.mpi_type = ioUtilGH->out_single ? PUGH_MPI_REAL4 : PUGH_MPI_REAL;
+ vtype = CCTK_VarTypeI (vindex);
+ /* downgrade the output precision if requested */
+ if (ioUtilGH->out_single)
+ {
+ /* 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.flexio_type = FLEXIO_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_CHAR:
- info.flexio_type = FLEXIO_CHAR;
- info.element_size = sizeof (CCTK_BYTE);
+ }
+ info.element_size = CCTK_VarTypeSize (vtype);
#ifdef CCTK_MPI
- info.mpi_type = PUGH_MPI_CHAR;
+ info.mpi_type = PUGH_MPIDataType (pughGH, vtype);
#endif
- break;
+ info.flexio_type = IOFlexIO_DataType (vtype);
-#if 0
-/* FIXME: Don't know how to support COMPLEX types too !! */
- case CCTK_VARIABLE_COMPLEX:
- info.flexio_type = ioUtilGH->out_single ? FLEXIO_REAL4 : FLEXIO_REAL;
- info.element_size = ioUtilGH->out_single ?
- 2 * sizeof (CCTK_REAL4) : 2 * sizeof (CCTK_REAL);
+ if (info.element_size <= 0 ||
#ifdef CCTK_MPI
- info.mpi_type = ioUtilGH->out_single ? PUGH_MPI_REAL4 : PUGH_MPI_REAL;
-#endif
- break;
+ info.mpi_type == MPI_DATATYPE_NULL ||
#endif
-
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
- "Unsupported variable type %d", variable_type);
- return;
+ info.flexio_type < 0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Unsupported variable type %d", vtype);
+ return;
}
switch (CCTK_GroupTypeFromVarI (vindex)) {
@@ -185,6 +180,62 @@ void IOFlexIO_DumpVar (cGH *GH, int vindex, int timelevel, IOFile iof)
}
+/*@@
+ @routine IOFlexIO_DataType
+ @author Thomas Radke
+ @date Mon 11 June 2001
+ @desc
+ Returns the FlexIO datatype for a given CCTK datatype
+ @enddesc
+
+ @var cctk_type
+ @vdesc CCTK datatype
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ the appropriate FlexIO datatype for success, or -1 otherwise
+ @endreturndesc
+@@*/
+int IOFlexIO_DataType (int cctk_type)
+{
+ int retval;
+
+
+ switch (cctk_type)
+ {
+ case CCTK_VARIABLE_CHAR: retval = FLEXIO_CHAR; break;
+ case CCTK_VARIABLE_INT: retval = FLEXIO_INT; break;
+ case CCTK_VARIABLE_REAL: retval = FLEXIO_REAL; break;
+#ifdef CCTK_INT2
+ case CCTK_VARIABLE_INT2: retval = FLEXIO_INT2; break;
+#endif
+#ifdef CCTK_INT4
+ case CCTK_VARIABLE_INT4: retval = FLEXIO_INT4; break;
+#endif
+#ifdef CCTK_INT8
+ case CCTK_VARIABLE_INT8: retval = FLEXIO_INT8; break;
+#endif
+#ifdef CCTK_REAL4
+ case CCTK_VARIABLE_REAL4: retval = FLEXIO_REAL4; break;
+#endif
+#ifdef CCTK_REAL8
+ case CCTK_VARIABLE_REAL8: retval = FLEXIO_REAL8; break;
+#endif
+#ifdef CCTK_REAL16
+ case CCTK_VARIABLE_REAL16: retval = FLEXIO_REAL16; break;
+#endif
+
+ default: CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Unsupported CCTK variable datatype %d", cctk_type);
+ retval = -1;
+ }
+
+ return (retval);
+}
+
/************************** local routines ******************************/
/*@@
diff --git a/src/Output3D.c b/src/Output3D.c
index fb90d13..be0bf0e 100644
--- a/src/Output3D.c
+++ b/src/Output3D.c
@@ -291,16 +291,18 @@ static void CheckSteerableParameters (flexioGH *myGH)
/* check if this variable can be output (static conditions) */
static int CheckOutputVar (int vindex)
{
- int vartype;
+ int retval;
char *fullname;
/*** FIXME: IEEEIO doesn't provide a COMPLEX datatype
- so somehow CCTK_COMPLEX has to be mapped onto REALs or so.
- We have to check this already here because if an IEEEIO file
- is created and nothing is written to, it crashes at re-opening. ***/
- vartype = CCTK_VarTypeI (vindex);
- if (vartype == CCTK_VARIABLE_COMPLEX)
+ so we should map CCTK_COMPLEX to two REALs here.
+ We have to check for this already here because if an IEEEIO file
+ is created and nothing is written to it, it will crash
+ at re-opening. ***/
+ retval = strncmp (CCTK_VarTypeName (CCTK_VarTypeI (vindex)),
+ "CCTK_VARIABLE_COMPLEX", 21);
+ if (! retval)
{
fullname = CCTK_FullName (vindex);
CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
@@ -309,7 +311,7 @@ static int CheckOutputVar (int vindex)
free (fullname);
}
- return (vartype == CCTK_VARIABLE_COMPLEX);
+ return (! retval);
}
diff --git a/src/RestoreFile.c b/src/RestoreFile.c
index e5ad7de..f85ce1e 100644
--- a/src/RestoreFile.c
+++ b/src/RestoreFile.c
@@ -177,32 +177,23 @@ int IOFlexIOi_RecoverVariables (cGH *GH, fileinfo_t *file)
IOread (file->fid, CCTK_VarDataPtrI (GH, timelevel, vindex)));
#ifdef CCTK_MPI
else {
- int dim, npoints;
+ int dim, npoints, vtype;
void *buffer;
int *chunkdims, *chunkorigin;
- int element_size;
+ int element_size, flexio_type;
MPI_Datatype mpi_type;
- switch (CCTK_VarTypeI (vindex)) {
- case CCTK_VARIABLE_CHAR:
- element_size = sizeof (CCTK_BYTE); mpi_type = PUGH_MPI_CHAR;
- break;
- case CCTK_VARIABLE_INT:
- element_size = sizeof (CCTK_INT); mpi_type = PUGH_MPI_INT;
- break;
- case CCTK_VARIABLE_REAL:
- element_size = sizeof (CCTK_REAL); mpi_type = PUGH_MPI_REAL;
- break;
-#if 0
-/* FIXME: Don't know how to support COMPLEX types too !! */
- case CCTK_VARIABLE_COMPLEX:
- element_size = sizeof (CCTK_COMPLEX);
- mpi_type = pughGH->PUGH_mpi_complex;
- break;
-#endif
- default:
- CCTK_WARN (1, "Unsupported datatype");
- continue;
+
+ vtype = CCTK_VarTypeI (vindex);
+ element_size = CCTK_VarTypeSize (vtype);
+ mpi_type = PUGH_MPIDataType (pughGH, vtype);
+ flexio_type = IOFlexIO_DataType (vtype);
+
+ if (element_size <= 0 || mpi_type == MPI_DATATYPE_NULL || flexio_type<0)
+ {
+ CCTK_VWarn (1, __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Unsupported variable type %d", vtype);
+ continue;
}
/* Get the pGExtras pointer as a shortcut */
diff --git a/src/ioFlexGH.h b/src/ioFlexGH.h
index b5ff5e0..8bb6cce 100644
--- a/src/ioFlexGH.h
+++ b/src/ioFlexGH.h
@@ -24,16 +24,29 @@
/* define the IOFlexIO datatypes according to CCTK_??? datatypes */
-#define FLEXIO_REAL4 FLOAT32
+#define FLEXIO_CHAR CHAR
+
+#ifdef CCTK_INT2
+#define FLEXIO_INT2 INT16
+#endif
+#ifdef CCTK_INT4
+#define FLEXIO_INT4 INT32
+#endif
+#ifdef CCTK_INT8
+#define FLEXIO_INT8 INT64
+#endif
-#ifdef CCTK_REAL_PRECISION_16
+#ifdef CCTK_REAL4
+#define FLEXIO_REAL4 FLOAT32
+#endif
+#ifdef CCTK_REAL8
+#define FLEXIO_REAL8 FLOAT64
+#endif
+#ifdef CCTK_REAL16
#error "128-bit precision floating point types are not supported by IOFlexIO !"
-#elif CCTK_REAL_PRECISION_8
-#define FLEXIO_REAL FLOAT64
-#elif CCTK_REAL_PRECISION_4
-#define FLEXIO_REAL FLOAT32
#endif
+/* define the FlexIO types for the generic CCTK_INT and CCTK_REAL datatypes */
#ifdef CCTK_INTEGER_PRECISION_8
#define FLEXIO_INT INT64
#elif CCTK_INTEGER_PRECISION_4
@@ -42,8 +55,13 @@
#define FLEXIO_INT INT16
#endif
-#define FLEXIO_INT4 INT32
-#define FLEXIO_CHAR CHAR
+#ifdef CCTK_REAL_PRECISION_4
+#define FLEXIO_REAL FLEXIO_REAL4
+#elif CCTK_REAL_PRECISION_8
+#define FLEXIO_REAL FLEXIO_REAL8
+#elif CCTK_REAL_PRECISION_16
+#define FLEXIO_REAL FLEXIO_REAL16
+#endif
/* attribute name for storing parameters
@@ -140,3 +158,4 @@ void IOFlexIO_Write3D (cGH *GH, int vindex, const char *alias);
void IOFlexIO_DumpVar (cGH *GH, int vindex, int timelevel, IOFile iof);
void IOFlexIO_IEEEIOStructDump (cGH *GH, IOFile iof);
void IOFlexIO_DumpGH (cGH *GH, int called_from);
+int IOFlexIO_DataType (int cctk_type);