aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschnetter <>2004-06-16 14:36:00 +0000
committerschnetter <>2004-06-16 14:36:00 +0000
commit187cb1a46a6b8e0e34bc4a93598fa843c816f97c (patch)
treed890c11bfb17420abafc806625ef5ecb5ecc5232
parent14c02185eb8b8d50561bcef6b72f0059c820fe13 (diff)
Add functions to access the MPI data type corresponding to the real
Add functions to access the MPI data type corresponding to the real data type corresponding to a (complex) data type. darcs-hash:20040616143602-07bb3-f96288d8410c367533ca39be0416ebdb27fc02f1.gz
-rw-r--r--Carpet/Carpet/src/carpet_public.h4
-rw-r--r--Carpet/Carpet/src/helpers.cc63
2 files changed, 65 insertions, 2 deletions
diff --git a/Carpet/Carpet/src/carpet_public.h b/Carpet/Carpet/src/carpet_public.h
index 15555f039..87c9130bc 100644
--- a/Carpet/Carpet/src/carpet_public.h
+++ b/Carpet/Carpet/src/carpet_public.h
@@ -1,4 +1,4 @@
-/* $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet_public.h,v 1.14 2004/05/21 18:16:23 schnetter Exp $ */
+/* $Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/carpet_public.h,v 1.15 2004/06/16 16:36:02 schnetter Exp $ */
#ifndef CARPET_PUBLIC_H
#define CARPET_PUBLIC_H
@@ -100,6 +100,8 @@ namespace Carpet {
/* Helper functions */
MPI_Comm CarpetMPIComm (void);
MPI_Datatype CarpetMPIDatatype (int vartype);
+ MPI_Datatype CarpetSimpleMPIDatatype (int vartype);
+ int CarpetSimpleMPIDatatypeLength (int vartype);
diff --git a/Carpet/Carpet/src/helpers.cc b/Carpet/Carpet/src/helpers.cc
index f075bd584..87289e6f0 100644
--- a/Carpet/Carpet/src/helpers.cc
+++ b/Carpet/Carpet/src/helpers.cc
@@ -17,7 +17,7 @@
#include "carpet.hh"
extern "C" {
- static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/helpers.cc,v 1.47 2004/05/21 18:16:23 schnetter Exp $";
+ static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/helpers.cc,v 1.48 2004/06/16 16:36:02 schnetter Exp $";
CCTK_FILEVERSION(Carpet_Carpet_helpers_cc);
}
@@ -127,6 +127,67 @@ namespace Carpet {
return MPI_CHAR;
}
+ MPI_Datatype CarpetSimpleMPIDatatype (const int vartype)
+ {
+ switch (vartype) {
+#ifdef CARPET_COMPLEX
+ case CCTK_VARIABLE_COMPLEX:
+ return CarpetMPIDatatype (CCTK_VARIABLE_REAL);
+#endif
+#ifdef CARPET_COMPLEX8
+# ifdef CCTK_REAL4
+ case CCTK_VARIABLE_COMPLEX8:
+ return CarpetMPIDatatype (CCTK_VARIABLE_REAL4);
+# endif
+#endif
+#ifdef CARPET_COMPLEX16
+# ifdef CCTK_REAL8
+ case CCTK_VARIABLE_COMPLEX16:
+ return CarpetMPIDatatype (CCTK_VARIABLE_REAL8);
+# endif
+#endif
+#ifdef CARPET_COMPLEX32
+# ifdef CCTK_REAL16
+ case CCTK_VARIABLE_COMPLEX32:
+ return CarpetMPIDatatype (CCTK_VARIABLE_REAL16);
+# endif
+#endif
+ default:
+ return CarpetMPIDatatype (vartype);
+ }
+ // notreached
+ return MPI_CHAR;
+ }
+
+ int CarpetSimpleMPIDatatypeLength (const int vartype)
+ {
+ switch (vartype) {
+#ifdef CARPET_COMPLEX
+ case CCTK_VARIABLE_COMPLEX:
+#endif
+#ifdef CARPET_COMPLEX8
+# ifdef CCTK_REAL4
+ case CCTK_VARIABLE_COMPLEX8:
+# endif
+#endif
+#ifdef CARPET_COMPLEX16
+# ifdef CCTK_REAL8
+ case CCTK_VARIABLE_COMPLEX16:
+# endif
+#endif
+#ifdef CARPET_COMPLEX32
+# ifdef CCTK_REAL16
+ case CCTK_VARIABLE_COMPLEX32:
+# endif
+#endif
+ return 2;
+ default:
+ return 1;
+ }
+ // notreached
+ return 0;
+ }
+
// Timelevels