blob: 499de64623bab50344314bf93525a99220c47555 (
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
|
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "dist.hh"
#include "carpet.hh"
namespace Carpet {
using namespace std;
int Shutdown (tFleshConfig* fc)
{
DECLARE_CCTK_PARAMETERS;
Waypoint ("Starting shutdown");
const int convlev = 0;
cGH* cgh = fc->GH[convlev];
for (int rl=reflevels-1; rl>=0; --rl) {
BEGIN_REVERSE_MGLEVEL_LOOP(cgh) {
enter_level_mode (cgh, rl);
do_global_mode = reflevel==0;
do_meta_mode = do_global_mode && mglevel==mglevels-1;
Checkpoint ("Shutdown at iteration %d time %g%s%s",
cgh->cctk_iteration, (double)cgh->cctk_time,
(do_global_mode ? " (global)" : ""),
(do_meta_mode ? " (meta)" : ""));
// Terminate
Checkpoint ("Scheduling TERMINATE");
CCTK_ScheduleTraverse ("CCTK_TERMINATE", cgh, CallFunction);
leave_level_mode (cgh);
} END_REVERSE_MGLEVEL_LOOP;
} // for rl
BEGIN_REVERSE_MGLEVEL_LOOP(cgh) {
do_global_mode = true;
do_meta_mode = mglevel==mglevels-1;
// Shutdown
Checkpoint ("Scheduling SHUTDOWN");
CCTK_ScheduleTraverse ("CCTK_SHUTDOWN", cgh, CallFunction);
} END_REVERSE_MGLEVEL_LOOP;
CCTK_PRINTSEPARATOR;
printf ("Done.\n");
// earlier checkpoint before finalising MPI
Waypoint ("Done with shutdown");
dist::finalize();
return 0;
}
} // namespace Carpet
|