YetAnotherCoupler 3.5.2
Loading...
Searching...
No Matches
core.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Thomas Jahns <jahns@dkrz.de>
2//
3// SPDX-License-Identifier: BSD-3-Clause
4
12/*
13 * Maintainer: Thomas Jahns <jahns@dkrz.de>
14 * URL: https://www.dkrz.de/redmine/projects/scales-ppm
15 *
16 * Redistribution and use in source and binary forms, with or without
17 * modification, are permitted provided that the following conditions are
18 * met:
19 *
20 * Redistributions of source code must retain the above copyright notice,
21 * this list of conditions and the following disclaimer.
22 *
23 * Redistributions in binary form must reproduce the above copyright
24 * notice, this list of conditions and the following disclaimer in the
25 * documentation and/or other materials provided with the distribution.
26 *
27 * Neither the name of the DKRZ GmbH nor the names of its contributors
28 * may be used to endorse or promote products derived from this software
29 * without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
32 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
33 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
34 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
35 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
36 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
37 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
38 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
39 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
40 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
41 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 *
43 * Commentary:
44 *
45 * The code in this file should be restricted to handle those parts
46 * the user program should keep as much control about as possible,
47 * like
48 *
49 * - error handling
50 * - file handling
51 *
52 * Thus the facilities provided here should always come with hooks
53 * for user-provided mechanisms.
54 *
55 * Code:
56 */
57
58#ifndef PPM_CORE_H
59#define PPM_CORE_H
60
61#include <mpi.h>
62#include <yaxt.h>
63
64#include "ppm/symprefix.h"
65
66// YAC PUBLIC HEADER START
67
68/* If we're not using GNU C, elide __attribute__ */
69#ifndef __GNUC__
70# define __attribute__(x) /*NOTHING*/
71#endif
72// #define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
73#define UNUSED(x) (void)(x)
74
78typedef void (*symprefix(abort_func))(MPI_Comm comm, const char *msg,
79 const char *source, int line)
80 __attribute__((noreturn));
81
89void symprefix(abort)(MPI_Comm comm, const char *msg,
90 const char *source, int line)
91 __attribute__((noreturn));
92
100void symprefix(abort_message)(char const *msg, const char *source, int line);
101
105void
107
112void
113symprefix(set_abort_handler)(symprefix(abort_func) custom_abort);
114
119symprefix(abort_func) symprefix(get_abort_handler)(void);
120
125symprefix(abort_func) symprefix(get_default_abort_handler)(void);
126
130extern void
131symprefix(set_default_comm)(MPI_Comm comm);
132
133static inline int
135{
136 int init_flag = 0, finished_flag = 0;
137 return MPI_Initialized(&init_flag) == MPI_SUCCESS && init_flag
138 && MPI_Finalized(&finished_flag) == MPI_SUCCESS && !finished_flag;
139}
140
141// YAC PUBLIC HEADER STOP
142
143#endif
144/*
145 * Local Variables:
146 * license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
147 * license-default: "bsd"
148 * license-markup: "doxygen"
149 * End:
150 */
void symprefix abort_message(char const *msg, const char *source, int line)
Definition core.c:100
void symprefix set_abort_handler(symprefix(abort_func) custom_abort)
Definition core.c:112
void symprefix set_default_comm(MPI_Comm comm)
Definition core.c:72
void symprefix abort(MPI_Comm comm, const char *msg, const char *source, int line) __attribute__((noreturn))
static int SymPrefix mpi_calls_are_allowed(void)
Definition core.h:134
void symprefix restore_default_abort_handler(void)
Definition core.c:106
#define __attribute__(x)
Definition core.h:70
Define library-specific symbol prefix macros.
#define SymPrefix(symbol)
Definition symprefix.h:55
#define symprefix(symbol)
Definition symprefix.h:57