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#define Terminate(...) \
16 { \
17 { \
18 char termbuf1__[8000], termbuf2__[8000]; \
19 int thistask; \
20 MPI_Comm_rank(MPI_COMM_WORLD, &thistask); \
21 sprintf(termbuf1__, "Code termination on task=%d, function %s(), file %s, line %d", thistask, __FUNCTION__, __FILE__, \
22 __LINE__); \
23 sprintf(termbuf2__, __VA_ARGS__); \
24 printf("%s: %s\n", termbuf1__, termbuf2__); \
25 fflush(stdout); \
26 MPI_Abort(MPI_COMM_WORLD, 1); \
27 } \
28 exit(0); \
29 }
30#define warn(...) \
31 { \
32 char termbuf1__[8000], termbuf2__[8000]; \
33 int thistask; \
34 MPI_Comm_rank(MPI_COMM_WORLD, &thistask); \
35 sprintf(termbuf1__, "Code warning on task=%d, function %s(), file %s, line %d", thistask, __FUNCTION__, __FILE__, __LINE__); \
36 sprintf(termbuf2__, __VA_ARGS__); \
37 printf("%s: %s\n", termbuf1__, termbuf2__); \
38 myflush(stdout); \
39 FILE *fd__ = fopen("WARNINGS", "w"); \
40 fclose(fd__); \
41 }
42
43#endif