source: pcp/src/errors.c@ 774ae8

Last change on this file since 774ae8 was a0bcf1, checked in by Frederik Heber <heber@…>, 17 years ago

-initial commit
-Minimum set of files needed from ESPACK SVN repository
-Switch to three tantamount package parts instead of all relating to pcp (as at some time Ralf's might find inclusion as well)

  • Property mode set to 100644
File size: 1.6 KB
Line 
1/** \file errors.c
2 * Error reporting.
3 * Contains just one function Error() which prints out a certain error message
4 * class and starts the debugger.
5 *
6 * Project: ParallelCarParrinello
7 * \author Jan Hamaekers
8 * \date 2000
9 *
10 * File: errors.c
11 * $Id: errors.c,v 1.11 2006/03/31 10:38:04 foo Exp $
12 *
13*/
14
15#include<stdlib.h>
16#include<stdio.h>
17#include"data.h"
18#include"opt.h"
19#include"errors.h"
20
21
22/** Deals with occuring errors.
23 * Prints process id followed by error according to \ref Errors.
24 * In the case of MallocError \a *SpecialData contains additional text.
25 * Launches debugger, does afterwards MPI_abort and exit
26 *
27 * \note One could add another pointer to a function
28 *
29 * \sa StartDebugger()
30 * \param error is the type of error(enum Errors) on error_msg array
31 * \param *SpecialData is a typeless pointer on special data for error treatment, here detailed error message.
32*/
33void Error(enum Errors error, const void *SpecialData)
34{
35 const char *const error_msg[] = {
36 "SomeError",
37 "FileOpenParams\nUnable to open parameter file",
38 "InitReading\n",
39 "MallocError\nUnable to allocate memory!",
40 };
41 int mytid;
42 MPI_Comm_rank(MPI_COMM_WORLD, &mytid);
43 fprintf(stderr, "\nProcess %i: ", mytid);
44 fprintf(stderr, "It has occured an error (%i): %s\n", error, error_msg[error]);
45 switch (error) {
46 case InitReading:
47 case SomeError:
48 case MallocError:
49 if (SpecialData) fprintf(stderr, "%s\n", (const char*)SpecialData);
50 break;
51 default:
52 break;
53 }
54
55 StartDebugger();
56 MPI_Abort(MPI_COMM_WORLD, (int)error);
57 exit(EXIT_FAILURE); /* exit schreibt sowieso alle Dateipuffer aus */
58}
Note: See TracBrowser for help on using the repository browser.