aboutsummaryrefslogtreecommitdiff
path: root/src/walltime.c
blob: 85209ede8e203b99cb1d905510ba77d55e658135 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
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);
  }
}