Yet Another eXchange Tool 0.11.1
Loading...
Searching...
No Matches
core.c
Go to the documentation of this file.
1
9/*
10 * Keywords: ScalES PPM error handling
11 * Maintainer: Thomas Jahns <jahns@dkrz.de>
12 * URL: https://swprojects.dkrz.de/redmine/projects/scales-ppm
13 *
14 * Redistribution and use in source and binary forms, with or without
15 * modification, are permitted provided that the following conditions are
16 * met:
17 *
18 * Redistributions of source code must retain the above copyright notice,
19 * this list of conditions and the following disclaimer.
20 *
21 * Redistributions in binary form must reproduce the above copyright
22 * notice, this list of conditions and the following disclaimer in the
23 * documentation and/or other materials provided with the distribution.
24 *
25 * Neither the name of the DKRZ GmbH nor the names of its contributors
26 * may be used to endorse or promote products derived from this software
27 * without specific prior written permission.
28 *
29 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
30 * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
31 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
32 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
33 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
34 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
35 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
36 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
37 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
38 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40 *
41 * Commentary:
42 *
43 * The code in this file should be restricted to handle those parts
44 * the user program should keep as much control about as possible,
45 * like
46 *
47 * - error handling
48 * - file handling
49 *
50 * Thus the facilities provided here should always come with hooks
51 * for user-provided mechanisms.
52 *
53 * Code:
54 */
55#ifdef HAVE_CONFIG_H
56# include <config.h>
57#endif
58#include <stdio.h>
59#include <stdlib.h>
60#ifndef WITHOUT_FORTRAN
61# if defined __clang__
62# pragma GCC diagnostic push
63# pragma GCC diagnostic ignored "-Wreserved-id-macro"
64# endif
65# include <cfortran.h>
66# if defined __clang__
67# pragma GCC diagnostic pop
68# endif
69# if defined __GNUC__
70# undef COMMON_BLOCK_DEF
71# define COMMON_BLOCK_DEF(DEFINITION, NAME) extern DEFINITION NAME __attribute__((aligned(16),common))
72# endif
73#endif
74#ifdef USE_MPI
75# include <mpi.h>
76#endif
77
78#include "core/ppm_visibility.h"
79#include "core/core.h"
80#include "core/symprefix.h"
81
83
84#ifndef WITHOUT_FORTRAN
85#define F2C_Data COMMON_BLOCK(SYMPREFIX(F2C_DATA),symprefix(f2c_data))
86
87typedef struct
88{
89 MPI_Fint symprefix(default_comm);
90} SymPrefix(F2C_Def);
91
93
95# if defined __GNUC__
96 __attribute__((aligned(16),common))
97# endif
98#endif
99 ;
100void
102{
103#ifndef WITHOUT_FORTRAN
104 MPI_Fint comm_f;
105# if defined(USE_MPI)
106 comm_f = MPI_Comm_c2f(comm);
107# else
108 comm_f = comm;
109# endif
110 F2C_Data.symprefix(default_comm) = comm_f;
111#endif
112 SymPrefix(default_comm) = comm;
113}
114
115void
116SymPrefix(abort_default)(MPI_Comm comm, const char *msg, const char *source, int line)
117{
118 fprintf(stderr, "Fatal error in %s, line %d: %s\n", source, line, msg);
119#ifdef USE_MPI
120#if defined (__xlC__) && defined (_AIX)
121#pragma omp critical
122#endif
123 if (SymPrefix(mpi_calls_are_allowed)())
124 MPI_Abort(comm, 1);
125 else
126 abort();
127#else
128 (void)comm;
129#endif
130 abort();
131}
132
134
135void
137{
139}
140
141/*
142 * Local Variables:
143 * license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
144 * license-markup: "doxygen"
145 * license-default: "bsd"
146 * End:
147 */
void SymPrefix() abort_default(MPI_Comm comm, const char *msg, const char *source, int line)
Definition core.c:116
#define F2C_Data
Definition core.c:85
COMMON_BLOCK_DEF(SymPrefix(F2C_Def), F2C_Data)
@ MPI_COMM_WORLD
Definition core.h:73
int MPI_Fint
Definition core.h:68
void SymPrefix() restore_default_abort_handler(void)
int MPI_Comm
Definition core.h:64
void SymPrefix() set_default_comm(MPI_Comm comm)
#define __attribute__(x)
Definition core.h:82
MPI_Fint symprefix(default_comm)
Define library-specific symbol prefix macros.