YetAnotherCoupler 3.2.0_a
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/* If we're not using GNU C, elide __attribute__ */
67#ifndef __GNUC__
68# define __attribute__(x) /*NOTHING*/
69#endif
70// #define UNUSED(x) UNUSED_ ## x __attribute__((__unused__))
71#define UNUSED(x) (void)(x)
72
76typedef void (*symprefix(abort_func))(MPI_Comm comm, const char *msg,
77 const char *source, int line)
78 __attribute__((noreturn));
79
87void symprefix(abort)(MPI_Comm comm, const char *msg,
88 const char *source, int line)
89 __attribute__((noreturn));
90
98void symprefix(abort_message)(char const *msg, const char *source, int line);
99
103void
105
110void
111symprefix(set_abort_handler)(symprefix(abort_func) custom_abort);
112
117symprefix(abort_func) symprefix(get_abort_handler)(void);
118
123symprefix(abort_func) symprefix(get_default_abort_handler)(void);
124
128extern void
129symprefix(set_default_comm)(MPI_Comm comm);
130
131static inline int
133{
134 int init_flag = 0, finished_flag = 0;
135 return MPI_Initialized(&init_flag) == MPI_SUCCESS && init_flag
136 && MPI_Finalized(&finished_flag) == MPI_SUCCESS && !finished_flag;
137}
138
139#endif
140/*
141 * Local Variables:
142 * license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
143 * license-default: "bsd"
144 * license-markup: "doxygen"
145 * End:
146 */
void symprefix() set_default_comm(MPI_Comm comm)
Definition core.c:72
static int SymPrefix() mpi_calls_are_allowed(void)
Definition core.h:132
void symprefix() set_abort_handler(symprefix(abort_func) custom_abort)
Definition core.c:110
void symprefix() restore_default_abort_handler(void)
Definition core.c:104
#define __attribute__(x)
Definition core.h:68
void symprefix() abort_message(char const *msg, const char *source, int line)
Definition core.c:98
void symprefix() abort(MPI_Comm comm, const char *msg, const char *source, int line) __attribute__((noreturn))
Define library-specific symbol prefix macros.
#define SymPrefix(symbol)
Definition symprefix.h:53
#define symprefix(symbol)
Definition symprefix.h:55