GADGET-4
macros.h
Go to the documentation of this file.
1 /*******************************************************************************
2  * \copyright This file is part of the GADGET4 N-body/SPH code developed
3  * \copyright by Volker Springel. Copyright (C) 2014-2020 by Volker Springel
4  * \copyright (vspringel@mpa-garching.mpg.de) and all contributing authors.
5  *******************************************************************************/
6 
12 #ifndef MACROS_H
13 #define MACROS_H
14 
15 #ifdef MPI_HYPERCUBE_ALLGATHERV
16 #define MPI_Allgatherv MPI_hypercube_Allgatherv
17 #endif
18 
19 #define Terminate(...) \
20  { \
21  { \
22  char termbuf1__[8000], termbuf2__[8000]; \
23  int thistask; \
24  MPI_Comm_rank(MPI_COMM_WORLD, &thistask); \
25  sprintf(termbuf1__, "Code termination on task=%d, function %s(), file %s, line %d", thistask, __FUNCTION__, __FILE__, \
26  __LINE__); \
27  sprintf(termbuf2__, __VA_ARGS__); \
28  printf("%s: %s\n", termbuf1__, termbuf2__); \
29  fflush(stdout); \
30  MPI_Abort(MPI_COMM_WORLD, 1); \
31  } \
32  exit(0); \
33  }
34 #define warn(...) \
35  { \
36  char termbuf1__[8000], termbuf2__[8000]; \
37  int thistask; \
38  MPI_Comm_rank(MPI_COMM_WORLD, &thistask); \
39  sprintf(termbuf1__, "Code warning on task=%d, function %s(), file %s, line %d", thistask, __FUNCTION__, __FILE__, __LINE__); \
40  sprintf(termbuf2__, __VA_ARGS__); \
41  printf("%s: %s\n", termbuf1__, termbuf2__); \
42  myflush(stdout); \
43  FILE *fd__ = fopen("WARNINGS", "w"); \
44  fclose(fd__); \
45  }
46 
47 #endif