summaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authoreschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2011-08-13 18:57:05 +0000
committereschnett <eschnett@17b73243-c579-4c4c-a9d2-2d5706c11dac>2011-08-13 18:57:05 +0000
commitee5b89f39619c06dd5d6f103eb5e4eac5135946b (patch)
tree424451037a101d535be1838280a00dbebaf8c07d /src/main
parent9dfdf64bce8369cf0a0c8d24ee3056eece974b80 (diff)
Flush stdout and stderr before and after outputting a parameter
warning. This helps prevent mixing of stdout and stderr when both are redirected to the same file. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4714 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/main')
-rw-r--r--src/main/DebugDefines.c134
-rw-r--r--src/main/WarnLevel.c6
2 files changed, 139 insertions, 1 deletions
diff --git a/src/main/DebugDefines.c b/src/main/DebugDefines.c
index 76f70b2f..bc7a68eb 100644
--- a/src/main/DebugDefines.c
+++ b/src/main/DebugDefines.c
@@ -11,6 +11,8 @@
#include "cctk_Config.h"
#include "cctk_Flesh.h"
#include "cctk_DebugDefines.h"
+#include "cctk_WarnLevel.h"
+#include "definethisthorn.h"
static const char *rcsid = "$Header$";
@@ -46,44 +48,174 @@ CCTK_FILEVERSION(main_DebugDefines_c);
the linear index for the given spatial indices
@endreturndesc
@@*/
+int CCTK_GFIndex0D (const cGH *GH)
+{
+ return (0);
+}
+
int CCTK_GFIndex1D (const cGH *GH, int i)
{
- GH = GH;
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d cctk_lsh=[%d]",
+ i, GH->cctk_lsh[0]);
+ }
+#endif
return (i);
}
int CCTK_GFIndex2D (const cGH *GH, int i, int j)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0] ||
+ j < 0 || j >= GH->cctk_lsh[1])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d j=%d cctk_lsh=[%d,%d]",
+ i, j, GH->cctk_lsh[0], GH->cctk_lsh[1]);
+ }
+#endif
return (i + GH->cctk_lsh[0]*j);
}
int CCTK_GFIndex3D (const cGH *GH, int i, int j, int k)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0] ||
+ j < 0 || j >= GH->cctk_lsh[1] ||
+ k < 0 || k >= GH->cctk_lsh[2])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d j=%d k=%d cctk_lsh=[%d,%d,%d]",
+ i, j, k, GH->cctk_lsh[0], GH->cctk_lsh[1], GH->cctk_lsh[2]);
+ }
+#endif
return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*k));
}
int CCTK_GFIndex4D (const cGH *GH, int i, int j, int k, int l)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0] ||
+ j < 0 || j >= GH->cctk_lsh[1] ||
+ k < 0 || k >= GH->cctk_lsh[2] ||
+ l < 0 || l >= GH->cctk_lsh[3])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d j=%d k=%d l=%d cctk_lsh=[%d,%d,%d,%d]",
+ i, j, k, l, GH->cctk_lsh[0], GH->cctk_lsh[1], GH->cctk_lsh[2], GH->cctk_lsh[3]);
+ }
+#endif
return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2] * l)));
}
+int CCTK_VectGFIndex0D (const cGH *GH, int n)
+{
+#ifdef CCTK_DEBUG
+ if (n < 0)
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Vector index out of bounds. n=%d",
+ n);
+ }
+#endif
+ return (n);
+}
+
int CCTK_VectGFIndex1D (const cGH *GH, int i, int n)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d cctk_lsh=[%d]",
+ i, GH->cctk_lsh[0]);
+ }
+ if (n < 0)
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Vector index out of bounds. n=%d",
+ n);
+ }
+#endif
return (i + GH->cctk_lsh[0]*n);
}
int CCTK_VectGFIndex2D (const cGH *GH, int i, int j, int n)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0] ||
+ j < 0 || j >= GH->cctk_lsh[1])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d j=%d cctk_lsh=[%d,%d]",
+ i, j, GH->cctk_lsh[0], GH->cctk_lsh[1]);
+ }
+ if (n < 0)
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Vector index out of bounds. n=%d",
+ n);
+ }
+#endif
return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*n));
}
int CCTK_VectGFIndex3D (const cGH *GH, int i, int j, int k, int n)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0] ||
+ j < 0 || j >= GH->cctk_lsh[1] ||
+ k < 0 || k >= GH->cctk_lsh[2])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d j=%d k=%d cctk_lsh=[%d,%d,%d]",
+ i, j, k, GH->cctk_lsh[0], GH->cctk_lsh[1], GH->cctk_lsh[2]);
+ }
+ if (n < 0)
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Vector index out of bounds. n=%d",
+ n);
+ }
+#endif
return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*n)));
}
int CCTK_VectGFIndex4D (const cGH *GH, int i, int j, int k, int l, int n)
{
+#ifdef CCTK_DEBUG
+ if (i < 0 || i >= GH->cctk_lsh[0] ||
+ j < 0 || j >= GH->cctk_lsh[1] ||
+ k < 0 || k >= GH->cctk_lsh[2] ||
+ l < 0 || l >= GH->cctk_lsh[3])
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Grid function index out of bounds. i=%d j=%d k=%d l=%d cctk_lsh=[%d,%d,%d,%d]",
+ i, j, k, l, GH->cctk_lsh[0], GH->cctk_lsh[1], GH->cctk_lsh[2], GH->cctk_lsh[3]);
+ }
+ if (n < 0)
+ {
+ CCTK_VWarn (CCTK_WARN_ABORT,
+ __LINE__, __FILE__, CCTK_THORNSTRING,
+ "Vector index out of bounds. n=%d",
+ n);
+ }
+#endif
return (i + GH->cctk_lsh[0]*(j + GH->cctk_lsh[1]*(k + GH->cctk_lsh[2]*
(l + GH->cctk_lsh[3]*n))));
}
diff --git a/src/main/WarnLevel.c b/src/main/WarnLevel.c
index a315ad73..c5557ffe 100644
--- a/src/main/WarnLevel.c
+++ b/src/main/WarnLevel.c
@@ -741,6 +741,8 @@ int CCTK_VParamWarn (const char *thorn,
highlight_warning_messages =
! highlight_warning_messages_ptr || *highlight_warning_messages_ptr;
+ fflush (stdout);
+
/* print to stderr */
if (highlight_warning_messages)
{
@@ -760,6 +762,8 @@ int CCTK_VParamWarn (const char *thorn,
bold_stderr (OFF);
}
+ fflush (stderr);
+
/* print to stdout */
if (highlight_warning_messages)
{
@@ -779,6 +783,8 @@ int CCTK_VParamWarn (const char *thorn,
bold_stdout (OFF);
}
+ fflush (stdout);
+
param_errors++;
return (0);