aboutsummaryrefslogtreecommitdiff
path: root/Carpet/Carpet/src/Shutdown.cc
blob: cc01fbd062609726a691a1300f1a754c7ad87f80 (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 <assert.h>
#include <stdio.h>
#include <stdlib.h>

#include "cctk.h"
#include "cctk_Parameters.h"

#include "dist.hh"

#include "carpet.hh"

extern "C" {
  static const char* rcsid = "$Header: /home/eschnett/C/carpet/Carpet/Carpet/Carpet/src/Shutdown.cc,v 1.12 2003/08/03 17:09:02 schnetter Exp $";
  CCTK_FILEVERSION(Carpet_Carpet_Shutdown_cc);
}



namespace Carpet {
  
  using namespace std;
  
  
  
  int Shutdown (tFleshConfig* fc)
  {
    DECLARE_CCTK_PARAMETERS;
    
    Waypoint ("starting Shutdown...");
    
    const int convlev = 0;
    cGH* cgh = fc->GH[convlev];
    
    Waypoint ("Current time is %g", cgh->cctk_time);
    
    BEGIN_REFLEVEL_LOOP(cgh) {
      BEGIN_MGLEVEL_LOOP(cgh) {
	
        do_global_mode = reflevel == 0;
        
	Waypoint ("%*sCurrent time is %g%s", 2*reflevel, "",
                  cgh->cctk_time,
                  do_global_mode ? "   (global time)" : "");
        
        // Terminate
        Waypoint ("%*sScheduling TERMINATE", 2*reflevel, "");
        CCTK_ScheduleTraverse ("CCTK_TERMINATE", cgh, CallFunction);
	
      } END_MGLEVEL_LOOP;
    } END_REFLEVEL_LOOP;
    
    do_global_mode = true;
    
    // Shutdown
    Waypoint ("Scheduling SHUTDOWN");
    CCTK_ScheduleTraverse ("CCTK_SHUTDOWN", cgh, CallFunction);
    
    CCTK_PRINTSEPARATOR;
    printf ("Done.\n");
    
    // earlier checkpoint before finalising MPI
    Waypoint ("done with Shutdown.");
    
    dist::finalize();
    
    return 0;
  }
  
} // namespace Carpet