summaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2006-12-19 12:04:02 +0000
committerschnetter <schnetter@17b73243-c579-4c4c-a9d2-2d5706c11dac>2006-12-19 12:04:02 +0000
commitf3b4f70df9431d800c644c803f6dd6601da52acb (patch)
tree67583c2048b674f3fe97b271f3d864273d5ac4ed /src/util
parenta76c73dcdb4bd0b84f1eb3a7cc21d84d6d5dc4db (diff)
Correct logic errors in CCTK_TimerPrintDataI:
Timer handles are not numbered consecutively from 0 upwards. It is therefore not possible to test for legal timer number by checking the range [0, CCTK_NumTimers()). Instead, for each timer handle one has to check whether handled data exist. Remove the feature that a timer number of -1 prints all existing timers, since it is not possible (?) to iterate over all existing timers. git-svn-id: http://svn.cactuscode.org/flesh/trunk@4396 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src/util')
-rw-r--r--src/util/CactusTimers.c74
1 files changed, 30 insertions, 44 deletions
diff --git a/src/util/CactusTimers.c b/src/util/CactusTimers.c
index a0cf74b4..cc4e75cb 100644
--- a/src/util/CactusTimers.c
+++ b/src/util/CactusTimers.c
@@ -1099,7 +1099,7 @@ static void CCTKi_Timer (int this_timer, t_Timer *timer, cTimerData *info)
total_vars = 0;
if (timer && timer->data)
{
- /* Start the timer info for this timer */
+ /* Get the timer info for this timer */
for (handle = 0; handle < n_clocks; handle++)
{
funcs = (const cClockFuncs *) Util_GetHandledData (clocks, handle);
@@ -1198,7 +1198,7 @@ int CCTK_TimerDestroyData (cTimerData *info)
@vio in
@endvar
@var this_clock
- @vdesc handle for the clock
+ @vdesc handle for the clock, or -1 for all clocks
@vtype int
@vio in
@endvar
@@ -1212,37 +1212,22 @@ int CCTK_TimerDestroyData (cTimerData *info)
int CCTK_TimerPrintDataI (int this_timer, int this_clock)
{
cTimerData *info;
- int i, timer, retval;
+ int i, retval;
int firstclock, lastclock;
- int firsttimer, lasttimer;
- retval = 0;
-
- if (this_timer == -1)
+ info = CCTK_TimerCreateData ();
+ retval = CCTK_TimerI (this_timer, info);
+ if (retval < 0)
{
- firsttimer = 0;
- lasttimer = CCTK_NumTimers ();
+ CCTK_VWarn (8, __LINE__, __FILE__, "Cactus",
+ "CCTK_TimerPrintDataI: Timer %d not found", this_timer);
+ retval = -1;
}
else
{
- firsttimer = this_timer;
- lasttimer = firsttimer + 1;
- if (firsttimer < 0 || firsttimer >= CCTK_NumTimers ())
- {
- CCTK_VWarn (8, __LINE__, __FILE__, "Cactus",
- "CCTK_TimerPrintDataI: Timer %d not found", this_timer);
- retval = -1;
- lasttimer = firsttimer;
- }
- }
-
- for (timer = firsttimer; timer < lasttimer; timer++)
- {
- info = CCTK_TimerCreateData ();
- CCTK_TimerI (timer, info); /* return values are always 0 */
- printf ("Results from timer \"%s\":\n", CCTK_TimerName (timer));
+ printf ("Results from timer \"%s\":\n", CCTK_TimerName (this_timer));
if (this_clock == -1)
{
@@ -1259,28 +1244,29 @@ int CCTK_TimerPrintDataI (int this_timer, int this_clock)
{
switch (info->vals[i].type)
{
- case val_int:
- printf ("\t%s: %d %s\n", info->vals[i].heading,
- info->vals[i].val.i, info->vals[i].units);
- break;
-
- case val_long:
- printf ("\t%s: %ld %s\n", info->vals[i].heading,
- info->vals[i].val.l, info->vals[i].units);
- break;
-
- case val_double:
- printf ("\t%s: %.3f %s\n", info->vals[i].heading,
- info->vals[i].val.d, info->vals[i].units);
- break;
-
- default:
- CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
- "CCTK_TimerPrintDataI: Unknown data type for timer info");
- break;
+ case val_int:
+ printf ("\t%s: %d %s\n", info->vals[i].heading,
+ info->vals[i].val.i, info->vals[i].units);
+ break;
+
+ case val_long:
+ printf ("\t%s: %ld %s\n", info->vals[i].heading,
+ info->vals[i].val.l, info->vals[i].units);
+ break;
+
+ case val_double:
+ printf ("\t%s: %.3f %s\n", info->vals[i].heading,
+ info->vals[i].val.d, info->vals[i].units);
+ break;
+
+ default:
+ CCTK_VWarn (1, __LINE__, __FILE__, "Cactus",
+ "CCTK_TimerPrintDataI: Unknown data type for timer info");
+ break;
}
}
CCTK_TimerDestroyData (info);
+
}
return (retval);