summaryrefslogtreecommitdiff
path: root/src/main/CactusDefaultShutdown.c
blob: 271fe273eede0434edc7f2e114a91f4d4c12a6cb (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
 /*@@
   @file      CactusDefaultShutdown.c
   @date      Fri Feb 26 16:53:58 1999
   @author    Tom Goodale
   @desc 
   The default shutdown routines.
   @enddesc 
 @@*/

#include <stdio.h>

#include "cctk.h"

#include "flesh.h"

#include "Comm.h"

#ifdef MPI
#include "mpi.h"
#endif


#ifdef MPI
extern char MPI_Active;
#endif

#ifdef MPI
#define CACTUS_MPI_ERROR(xf)  do {int errcode; \
                                    if((errcode = xf) != MPI_SUCCESS)                     \
				    {                                                     \
				      char mpi_error_string[MPI_MAX_ERROR_STRING+1];      \
				      int resultlen;                                      \
				      MPI_Error_string(errcode, mpi_error_string, &resultlen);\
				      fprintf(stderr, "MPI Call %s returned error code %d (%s)\n", \
                                      #xf, errcode, mpi_error_string);                    \
				      fprintf(stderr, "At line %d of file %s\n",                   \
					     __LINE__, __FILE__);                         \
				    }                                                     \
				  } while (0)
#endif

 /*@@
   @routine    CactusDefaultShutdown
   @date       Tue Sep 29 12:45:04 1998
   @author     Tom Goodale
   @desc 
   DEfault shutdown routine.
   @enddesc 
   @calls     
   @calledby   
   @history 
 
   @endhistory 

@@*/
int CactusDefaultShutdown(tFleshConfig *config)
{
  int myproc;

  myproc = CCTK_MyProc(config->GH[0]);

#ifdef MPI
  if(MPI_Active)
  {
    CACTUS_MPI_ERROR(MPI_Finalize());
  }
#endif

  if(myproc == 0)
  {
    /* printf("Goodbye! Adeu! Adios! Tchuess! Au Revoir! Ciao! Math sin leat!\n"); */
    printf("-------------------------------------------------------------------------------------\n");
    printf("Done.\n");
  }

  return 0;
}