Yet Another eXchange Tool  DO_NOT_EDIT_HERE
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://www.dkrz.de/redmine/projects/show/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 #if defined __clang__
60 #pragma GCC diagnostic push
61 #pragma GCC diagnostic ignored "-Wreserved-id-macro"
62 #endif
63 #include <cfortran.h>
64 #if defined __clang__
65 #pragma GCC diagnostic pop
66 #endif
67 
68 #include "core.h"
69 #include "symprefix.h"
70 
71 MPI_Comm SymPrefix(default_comm) = MPI_COMM_WORLD;
72 
73 #define XT_F2C_Data COMMON_BLOCK(XT_F2C_DATA,xt_f2c_data)
74 
75 typedef struct
76 {
78 } XT_F2C_Def;
79 
81 
83 
84 void
86 {
87  MPI_Fint comm_f;
88 #if defined(USE_MPI)
89  comm_f = MPI_Comm_c2f(comm);
90 #else
91  comm_f = comm;
92 #endif
93  SymPrefix(default_comm) = comm;
94  XT_F2C_Data.xt_default_comm = comm_f;
95 }
96 
97 void
98 SymPrefix(abort_default)(MPI_Comm comm, const char *msg, const char *source, int line)
99 {
100  int flag = 0;
101  fprintf(stderr, "Fatal error in %s, line %d: %s\n", source, line, msg);
102 #ifdef USE_MPI
103 #if defined (__xlC__) && defined (_AIX)
104 #pragma omp critical
105 #endif
106  if (MPI_Initialized(&flag) == MPI_SUCCESS && flag)
107  MPI_Abort(comm, 1);
108 #endif
109  abort();
110 }
111 
113 
114 void
116 {
118 }
119 
120 #if (defined __GNUC__ && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))\
121  || (defined __clang__)
122 #pragma GCC diagnostic push
123 #pragma GCC diagnostic ignored "-Wmissing-prototypes"
124 #endif
126  SYMPREFIX(RESTORE_DEFAULT_ABORT_HNDL),
127  symprefix(restore_default_abort_hndl))
128 #if (defined __GNUC__ && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))\
129  || (defined __clang__)
130 #pragma GCC diagnostic pop
131 #endif
132 
133 /*
134  * Local Variables:
135  * license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
136  * license-markup: "doxygen"
137  * license-default: "bsd"
138  * End:
139  */
#define SYMPREFIX(symbol)
Definition: symprefix.h:51
int MPI_Fint
Definition: core.h:68
Define library-specific symbol prefix macros.
MPI_Fint xt_default_comm
Definition: core.c:77
#define symprefix(symbol)
Definition: symprefix.h:55
void SymPrefix() set_default_comm(MPI_Comm comm)
Definition: core.c:85
void SymPrefix() abort_default(MPI_Comm comm, const char *msg, const char *source, int line)
Definition: core.c:98
COMMON_BLOCK_DEF(XT_F2C_Def, XT_F2C_Data)
#define XT_F2C_Data
Definition: core.c:73
void SymPrefix() restore_default_abort_handler(void)
int MPI_Comm
Definition: core.h:64
MPI_Comm SymPrefix(default_comm)