Commit 438a26bf authored by Thomas Jahns's avatar Thomas Jahns 🤸
Browse files

Align fail-safe wrappers with YAXT.

parent b93d06e0
......@@ -277,6 +277,7 @@ endif
libscalesppm_la_SOURCES += \
core/errhandler.c \
core/errhandler.h \
core/ppm_xmpi.c \
core/ppm_extents_mp.f90 \
core/ppm_extents_mp_c.c \
core/ppm_extents_mp.h \
......@@ -290,6 +291,7 @@ libscalesppm_la_SOURCES += \
libscalesppmcore_la_SOURCES += \
core/errhandler.c \
core/errhandler.h \
core/ppm_xmpi.c \
core/ppm_std_type_kinds_mp_c.c \
core/ppm_std_type_kinds_mp.h \
core/ppm_math_extensions_ddp_mp_c.c \
......
......@@ -53,50 +53,57 @@
* Code:
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include <stdio.h>
#if defined __clang__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wreserved-id-macro"
#pragma GCC diagnostic ignored "-Wstrict-prototypes"
#include <stdlib.h>
#ifndef WITHOUT_FORTRAN
# if defined __clang__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wreserved-id-macro"
# pragma GCC diagnostic ignored "-Wstrict-prototypes"
# endif
# include <cfortran.h>
# if defined __clang__
# pragma GCC diagnostic pop
# endif
#endif
#include <cfortran.h>
#if defined __clang__
#pragma GCC diagnostic pop
#endif
#ifdef USE_MPI
#include <mpi.h>
# include <mpi.h>
#endif
#include "core/ppm_visibility.h"
#include "core/core.h"
#include "core/symprefix.h"
MPI_Comm SymPrefix(default_comm) = MPI_COMM_WORLD;
#define SymPrefix(F2C_Data) COMMON_BLOCK(SYMPREFIX(F2C_DATA),symprefix(f2c_data))
#ifndef WITHOUT_FORTRAN
#define F2C_Data COMMON_BLOCK(SYMPREFIX(F2C_DATA),symprefix(f2c_data))
typedef struct
{
MPI_Fint symprefix(default_comm);
} SymPrefix(F2C_Def);
COMMON_BLOCK_DEF(SYMPREFIX(F2C_Def),SymPrefix(F2C_Data));
COMMON_BLOCK_DEF(SymPrefix(F2C_Def),F2C_Data);
SymPrefix(F2C_Def) SymPrefix(F2C_Data);
SymPrefix(F2C_Def) F2C_Data;
#endif
void
SymPrefix(set_default_comm)(MPI_Comm comm)
{
#ifndef WITHOUT_FORTRAN
MPI_Fint comm_f;
#if defined(USE_MPI)
# if defined(USE_MPI)
comm_f = MPI_Comm_c2f(comm);
#else
# else
comm_f = comm;
# endif
F2C_Data.symprefix(default_comm) = comm_f;
#endif
SymPrefix(default_comm) = comm;
SymPrefix(F2C_Data).symprefix(default_comm) = comm_f;
}
void
......@@ -125,48 +132,6 @@ SymPrefix(restore_default_abort_handler)(void)
SymPrefix(abort) = SymPrefix(abort_default);
}
#if (defined __GNUC__ && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))\
|| (defined __clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#endif
FCALLSCSUB0(SymPrefix(restore_default_abort_handler),
SYMPREFIX(RESTORE_DEFAULT_ABORT_HNDL),
symprefix(restore_default_abort_hndl))
#if (defined __GNUC__ && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))\
|| (defined __clang__)
#pragma GCC diagnostic pop
#endif
#ifdef USE_MPI
static inline int
getMPICommWorldRank()
{
int rank = -1;
if (SymPrefix(mpi_calls_are_allowed)())
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
return rank;
}
void
SymPrefix(xmpi)(int errcode, const char *source, int line)
{
char errorString[2][MPI_MAX_ERROR_STRING + 1];
int lenES, lenEC, errorClass, rank = getMPICommWorldRank();
MPI_Error_class(errcode, &errorClass);
MPI_Error_string(errorClass, errorString[0], &lenEC);
MPI_Error_string(errcode, errorString[1], &lenES);
errorString[0][MPI_MAX_ERROR_STRING] = 0;
errorString[1][MPI_MAX_ERROR_STRING] = 0;
fprintf(stderr, "MPI ERROR, pe%d, %s, line %d,"
"errorClass: \"%*s\""
"errorString: \"%*s\"\n",
rank, source, line,
lenEC, errorString[0], lenES, errorString[1]);
MPI_Abort(MPI_COMM_WORLD, 1);
}
#endif
/*
* Local Variables:
* license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
......
......@@ -39,7 +39,7 @@
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
# include <config.h>
#endif
#include <stdio.h>
......@@ -121,6 +121,19 @@ abort_default_f(MPI_Fint *comm_f, const char *msg, const char *source,
#undef FCALLSC_QUALIFIER
#define FCALLSC_QUALIFIER
#if (defined __GNUC__ && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))\
|| (defined __clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmissing-prototypes"
#endif
FCALLSCSUB0(SymPrefix(restore_default_abort_handler),
SYMPREFIX(RESTORE_DEFAULT_ABORT_HNDL),
symprefix(restore_default_abort_hndl))
#if (defined __GNUC__ && __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5))\
|| (defined __clang__)
#pragma GCC diagnostic pop
#endif
FCALLSCSUB4(abort_default_f,SYMPREFIX(ABORT_DEFAULT),
symprefix(abort_default),
PVOID,STRING,STRING,INT)
......
......@@ -10,7 +10,7 @@
/*
* Keywords: fail-safe wrappers
* Maintainer: Thomas Jahns <jahns@dkrz.de>
* URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
* URL: https://www.dkrz.de/redmine/projects/scales-ppm
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -43,11 +43,15 @@
#ifndef PPM_XFUNCS_INCLUDED
#define PPM_XFUNCS_INCLUDED
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef USE_MPI
#include <mpi.h>
# include <mpi.h>
#endif
#include "core/symprefix.h"
......@@ -97,7 +101,7 @@ SymPrefix(xmpi)(int errcode, const char *source, int line);
#endif
/*
* Local Variables:
* license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
* license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
* license-markup: "doxygen"
* license-default: "bsd"
* End:
......
/*
* @file ppm_xmpi.c
* @brief ScalES-PPM core library C/Fortran interface
*
* Copyright (C) 2020 Thomas Jahns <jahns@dkrz.de>
*
* @version 1.0
* Keywords:
* @author Thomas Jahns <jahns@dkrz.de>
* Maintainer: Thomas Jahns <jahns@dkrz.de>
* URL: https://www.dkrz.de/redmine/projects/scales-ppm
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
*
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the DKRZ GmbH nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <stdio.h>
#include "core/core.h"
#include "core/symprefix.h"
#include "core/ppm_xfuncs.h"
static inline int
getMPICommWorldRank()
{
int rank = -1;
if (SymPrefix(mpi_calls_are_allowed)())
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
return rank;
}
void
SymPrefix(xmpi)(int errcode, const char *source, int line)
{
char errorString[2][MPI_MAX_ERROR_STRING + 1];
int lenES, lenEC, errorClass, rank = getMPICommWorldRank();
MPI_Error_class(errcode, &errorClass);
MPI_Error_string(errorClass, errorString[0], &lenEC);
MPI_Error_string(errcode, errorString[1], &lenES);
errorString[0][MPI_MAX_ERROR_STRING] = 0;
errorString[1][MPI_MAX_ERROR_STRING] = 0;
fprintf(stderr, "MPI ERROR, pe%d, %s, line %d,"
"errorClass: \"%*s\""
"errorString: \"%*s\"\n",
rank, source, line,
lenEC, errorString[0], lenES, errorString[1]);
MPI_Abort(MPI_COMM_WORLD, 1);
}
......@@ -9,7 +9,7 @@
*/
/*
* Maintainer: Thomas Jahns <jahns@dkrz.de>
* URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
* URL: https://www.dkrz.de/redmine/projects/scales-ppm
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -38,6 +38,9 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <stdlib.h>
......@@ -85,7 +88,7 @@ SymPrefix(xrealloc)(void *ptr, size_t size, const char *source, int line)
/*
* Local Variables:
* license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
* license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
* license-markup: "doxygen"
* license-default: "bsd"
* End:
......
......@@ -9,7 +9,7 @@
*/
/*
* Maintainer: Thomas Jahns <jahns@dkrz.de>
* URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
* URL: https://www.dkrz.de/redmine/projects/scales-ppm
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
......@@ -38,6 +38,10 @@
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <errno.h>
#include <stdio.h>
#include <string.h>
......@@ -74,7 +78,7 @@ SymPrefix(xfputc)(int c, FILE *stream, const char *source, int line)
}
/*
* Local Variables:
* license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
* license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
* license-markup: "doxygen"
* license-default: "bsd"
* End:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment