This contains an example of how to use yac_abort_message.
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <mpi.h>
#include "tests.h"
static void custom_error_handler(
MPI_Comm comm, const char * msg, const char * source, int line);
char const * ref_msg = "reference message";
char const * ref_source = __FILE__;
int const ref_line = __LINE__;
MPI_Comm ref_comm_world;
MPI_Init(NULL, NULL);
MPI_Comm_dup(MPI_COMM_WORLD, &ref_comm_world);
PUT_ERR("error in yac_get_abort_handler/yac_get_default_abort_handler");
PUT_ERR("error in yac_get_abort_handler");
PUT_ERR("error in yac_get_abort_handler/yac_get_default_abort_handler");
PUT_ERR("yac_abort_default did not abort program");
MPI_Finalize();
return TEST_EXIT_CODE;
}
static void custom_error_handler(
MPI_Comm comm, const char * msg, const char * source, int line) {
int result;
MPI_Comm_compare(comm, ref_comm_world, &result);
if (result != MPI_IDENT) PUT_ERR("error in yac_abort_message (comm)");
if (strcmp(msg, ref_msg)) PUT_ERR("error in yac_abort_message (msg)");
if (strcmp(source, ref_source)) PUT_ERR("error in yac_abort_message (source)");
if (line != ref_line) PUT_ERR("error in yac_abort_message (line)");
MPI_Finalize();
exit(TEST_EXIT_CODE);
}
int main(int argc, char **argv)
yac_abort_func yac_get_abort_handler(void)
void yac_set_default_comm(MPI_Comm comm)
void(* yac_abort_func)(MPI_Comm comm, const char *msg, const char *source, int line) __attribute__((noreturn))
void yac_restore_default_abort_handler(void)
yac_abort_func yac_get_default_abort_handler(void)
void yac_set_abort_handler(yac_abort_func custom_abort)
void yac_abort_message(char const *, char const *, int)