aboutsummaryrefslogtreecommitdiff
path: root/src/walltime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/walltime.c')
-rw-r--r--src/walltime.c81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/walltime.c b/src/walltime.c
new file mode 100644
index 0000000..85209ed
--- /dev/null
+++ b/src/walltime.c
@@ -0,0 +1,81 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "cctk.h"
+#include "cctk_Arguments.h"
+#include "cctk_Parameters.h"
+#include "cctk_Termination.h"
+#include "cctk_Timers.h"
+
+
+
+void TerminationTrigger_StartTimer (CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ /* only one processor needs to query the elapsed runtime */
+ if (CCTK_MyProc (cctkGH) != 0)
+ {
+ return;
+ }
+
+ *watchminutes = output_remtime_every_minutes;
+
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "Reminding you every %g minutes about remaining walltime",
+ (double) output_remtime_every_minutes);
+}
+
+
+
+void TerminationTrigger_ResetMinutes (CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ /* only one processor needs to query the elapsed runtime */
+ if (CCTK_MyProc (cctkGH) != 0)
+ {
+ return;
+ }
+
+ *watchminutes = output_remtime_every_minutes;
+}
+
+
+
+void TerminationTrigger_CheckWalltime (CCTK_ARGUMENTS)
+{
+ DECLARE_CCTK_ARGUMENTS;
+ DECLARE_CCTK_PARAMETERS;
+
+ CCTK_REAL time;
+
+ /* only one processor needs to query the elapsed runtime */
+ if (CCTK_MyProc (cctkGH) != 0)
+ {
+ return;
+ }
+
+ /* get walltime in seconds */
+ time = CCTK_RunTime();
+
+ if ((time/60.0 > *watchminutes) && *watchminutes != 0) {
+ *watchminutes += output_remtime_every_minutes;
+ CCTK_INFO ("***********************************************************");
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "Remaining wallclock time for your job is %g minutes",
+ (double) (max_walltime*60.0 - time/60.0));
+ CCTK_INFO ("***********************************************************");
+ }
+
+ if (time/60.0 >= (max_walltime*60.0 - on_remaining_walltime)) {
+ CCTK_VInfo (CCTK_THORNSTRING,
+ "Remaining wallclock time for your job is %g minutes. "
+ "Triggering termination...",
+ (double) (max_walltime*60.0 - time/60.0));
+ CCTK_TerminateNext (cctkGH);
+ }
+}