-
Notifications
You must be signed in to change notification settings - Fork 26
/
Copy pathhypre_error.c
89 lines (73 loc) · 2.46 KB
/
hypre_error.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*BHEADER**********************************************************************
* Copyright (c) 2017, Lawrence Livermore National Security, LLC.
* Produced at the Lawrence Livermore National Laboratory.
* Written by Ulrike Yang ([email protected]) et al. CODE-LLNL-738-322.
* This file is part of AMG. See files README and COPYRIGHT for details.
*
* AMG is free software; you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License (as published by the Free
* Software Foundation) version 2.1 dated February 1999.
*
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTIBILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the terms and conditions of the
* GNU General Public License for more details.
*
***********************************************************************EHEADER*/
#include "_hypre_utilities.h"
HYPRE_Int hypre__global_error = 0;
/* Process the error with code ierr raised in the given line of the
given source file. */
void hypre_error_handler(const char *filename, HYPRE_Int line, HYPRE_Int ierr, const char *msg)
{
hypre_error_flag |= ierr;
#ifdef HYPRE_PRINT_ERRORS
if (msg)
{
hypre_fprintf(
stderr, "hypre error in file \"%s\", line %d, error code = %d - %s\n",
filename, line, ierr, msg);
}
else
{
hypre_fprintf(
stderr, "hypre error in file \"%s\", line %d, error code = %d\n",
filename, line, ierr);
}
#endif
}
HYPRE_Int HYPRE_GetError()
{
return hypre_error_flag;
}
HYPRE_Int HYPRE_CheckError(HYPRE_Int ierr, HYPRE_Int hypre_error_code)
{
return ierr & hypre_error_code;
}
void HYPRE_DescribeError(HYPRE_Int ierr, char *msg)
{
if (ierr == 0)
hypre_sprintf(msg,"[No error] ");
if (ierr & HYPRE_ERROR_GENERIC)
hypre_sprintf(msg,"[Generic error] ");
if (ierr & HYPRE_ERROR_MEMORY)
hypre_sprintf(msg,"[Memory error] ");
if (ierr & HYPRE_ERROR_ARG)
hypre_sprintf(msg,"[Error in argument %d] ", HYPRE_GetErrorArg());
if (ierr & HYPRE_ERROR_CONV)
hypre_sprintf(msg,"[Method did not converge] ");
}
HYPRE_Int HYPRE_GetErrorArg()
{
return (hypre_error_flag>>3 & 31);
}
HYPRE_Int HYPRE_ClearAllErrors()
{
hypre_error_flag = 0;
return (hypre_error_flag != 0);
}
HYPRE_Int HYPRE_ClearError(HYPRE_Int hypre_error_code)
{
hypre_error_flag &= ~hypre_error_code;
return (hypre_error_flag & hypre_error_code);
}