summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorknarf <knarf@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-10-24 20:03:13 +0000
committerknarf <knarf@17b73243-c579-4c4c-a9d2-2d5706c11dac>2012-10-24 20:03:13 +0000
commitc1ee98289170c1bc140fb3519580c9f7eceb8baf (patch)
tree7ab9e1934433382fed5b3a3d2673780f83950ffa /src
parent7b408d1cc5125e2a9ef4da8194cbd752312ffe13 (diff)
Added CCTK_TimerRunning and CCTK_TimerRunningI
These functions return whether a Cactus timer is running or not (either by name or by handle). git-svn-id: http://svn.cactuscode.org/flesh/trunk@4890 17b73243-c579-4c4c-a9d2-2d5706c11dac
Diffstat (limited to 'src')
-rw-r--r--src/include/cctk_Timers.h2
-rw-r--r--src/main/ScheduleInterface.c11
-rw-r--r--src/util/CactusTimers.c95
3 files changed, 106 insertions, 2 deletions
diff --git a/src/include/cctk_Timers.h b/src/include/cctk_Timers.h
index 764e2c6d..53b55bfd 100644
--- a/src/include/cctk_Timers.h
+++ b/src/include/cctk_Timers.h
@@ -77,6 +77,8 @@ int CCTK_TimerStop(const char *name);
int CCTK_TimerStopI(int this_timer);
int CCTK_TimerReset(const char *name);
int CCTK_TimerResetI(int this_timer);
+int CCTK_TimerIsRunning(const char *name);
+int CCTK_TimerIsRunningI(int this_timer);
int CCTK_Timer(const char *name, cTimerData *info);
int CCTK_TimerI(int this_timer, cTimerData *info);
diff --git a/src/main/ScheduleInterface.c b/src/main/ScheduleInterface.c
index 5f549dc1..e267e0b4 100644
--- a/src/main/ScheduleInterface.c
+++ b/src/main/ScheduleInterface.c
@@ -1253,13 +1253,20 @@ int CCTK_SchedulePrintTimesToFile(const char *where, FILE *file)
/* also print total time at the bottom */
if (total_timer >= 0)
{
- CCTK_TimerStopI (total_timer);
+ int total_timer_running = CCTK_TimerIsRunningI(total_timer);
+ if (total_timer_running)
+ {
+ CCTK_TimerStopI (total_timer);
+ }
CCTK_TimerI (total_timer, timerinfo);
CCTKi_SchedulePrintTimerInfo
(timerinfo, NULL, "", "Total time for simulation", file);
/* just in case this is not at termination yet ... */
- CCTK_TimerStartI (total_timer);
+ if (total_timer_running)
+ {
+ CCTK_TimerStartI (total_timer);
+ }
}
return 0;
diff --git a/src/util/CactusTimers.c b/src/util/CactusTimers.c
index 1f6b718a..ec7005d4 100644
--- a/src/util/CactusTimers.c
+++ b/src/util/CactusTimers.c
@@ -54,6 +54,10 @@ void CCTK_FCALL CCTK_FNAME (CCTK_TimerPrintDataI)
(int *ierr, int *this_timer, int *this_clock);
void CCTK_FCALL CCTK_FNAME (CCTK_TimerPrintData)
(int *ierr, TWO_FORTSTRING_ARG);
+void CCTK_FCALL CCTK_FNAME (CCTK_TimerIsRunningI)
+ (int *ierr, int *this_timer);
+void CCTK_FCALL CCTK_FNAME (CCTK_TimerIsRunning)
+ (int *ierr, ONE_FORTSTRING_ARG);
/********************************************************************
@@ -1017,6 +1021,97 @@ static void CCTKi_TimerReset (int this_timer, t_Timer *timer)
/*@@
+ @routine CCTK_TimerIsRunningI
+ @date Wed Oct 24 2012 13:00:00
+ @author Frank Löffler
+ @desc
+ Returns if a timer is currently running given by its handle.
+ @enddesc
+ @calls
+
+ @var this_timer
+ @vdesc handle for the timer
+ @vtype int
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 for no (or failure to lookup timer), 1 for yes
+ @endreturndesc
+@@*/
+int CCTK_TimerIsRunningI (int this_timer)
+{
+ t_Timer *timer;
+
+
+ timer = Util_GetHandledData (timers, this_timer);
+ if (timer)
+ {
+ return !!timer->running;
+ }
+ else
+ {
+ CCTK_VWarn (8, __LINE__, __FILE__, "Cactus",
+ "CCTK_TimerIsRunningI: Timer %d not found",this_timer);
+ }
+ return 0;
+}
+
+void CCTK_FCALL CCTK_FNAME (CCTK_TimerIsRunningI)
+ (int *ierr, int *this_timer)
+{
+ *ierr = CCTK_TimerIsRunningI (*this_timer);
+}
+
+ /*@@
+ @routine CCTK_TimerIsRunning
+ @date Wed Oct 24 13:00:00
+ @author Frank Löffler
+ @desc
+ Returns if a timer is currently running.
+ @enddesc
+ @calls CCTK_TimerIsRunningI
+
+ @var timername
+ @vdesc name of the timer
+ @vtype const char *
+ @vio in
+ @endvar
+
+ @returntype int
+ @returndesc
+ 0 for no (or failure to lookup timer), 1 for yes
+ @endreturndesc
+@@*/
+int CCTK_TimerIsRunning (const char *timername)
+{
+ t_Timer *timer;
+ int this_timer;
+
+
+ this_timer = Util_GetHandle (timers, timername, (void **) &timer);
+ if (this_timer >= 0)
+ {
+ return CCTK_TimerIsRunningI (this_timer);
+ }
+ else
+ {
+ CCTK_VWarn (8, __LINE__, __FILE__, "Cactus",
+ "CCTK_TimerIsRunning: Timer %s not found",timername);
+ }
+ return 0;
+}
+
+void CCTK_FCALL CCTK_FNAME (CCTK_TimerIsRunning)
+ (int *ierr, ONE_FORTSTRING_ARG)
+{
+ ONE_FORTSTRING_CREATE (timername)
+ *ierr = CCTK_TimerIsRunning (timername);
+ free (timername);
+}
+
+ /*@@
@routine CCTK_Timer
@date Wed Sep 1 10:10:38 1999
@author Tom Goodale