| [2aa6644] | 1 | /*BHEADER**********************************************************************
|
|---|
| 2 | * Copyright (c) 2008, Lawrence Livermore National Security, LLC.
|
|---|
| 3 | * Produced at the Lawrence Livermore National Laboratory.
|
|---|
| 4 | * This file is part of HYPRE. See file COPYRIGHT for details.
|
|---|
| 5 | *
|
|---|
| 6 | * HYPRE is free software; you can redistribute it and/or modify it under the
|
|---|
| 7 | * terms of the GNU Lesser General Public License (as published by the Free
|
|---|
| 8 | * Software Foundation) version 2.1 dated February 1999.
|
|---|
| 9 | *
|
|---|
| 10 | * $Revision: 2.4 $
|
|---|
| 11 | ***********************************************************************EHEADER*/
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 | #include "utilities.h"
|
|---|
| 15 |
|
|---|
| 16 | int hypre__global_error = 0;
|
|---|
| 17 |
|
|---|
| 18 | /* Process the error with code ierr raised in the given line of the
|
|---|
| 19 | given source file. */
|
|---|
| 20 | void hypre_error_handler(char *filename, int line, int ierr)
|
|---|
| 21 | {
|
|---|
| 22 | hypre_error_flag |= ierr;
|
|---|
| 23 |
|
|---|
| 24 | #ifdef HYPRE_PRINT_ERRORS
|
|---|
| 25 | fprintf(stderr,
|
|---|
| 26 | "hypre error in file \"%s\", line %d, error code = %d ",
|
|---|
| 27 | filename, line, ierr);
|
|---|
| 28 | #endif
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | int HYPRE_GetError()
|
|---|
| 32 | {
|
|---|
| 33 | return hypre_error_flag;
|
|---|
| 34 | }
|
|---|
| 35 |
|
|---|
| 36 | int HYPRE_CheckError(int ierr, int hypre_error_code)
|
|---|
| 37 | {
|
|---|
| 38 | return ierr & hypre_error_code;
|
|---|
| 39 | }
|
|---|
| 40 |
|
|---|
| 41 | void HYPRE_DescribeError(int ierr, char *msg)
|
|---|
| 42 | {
|
|---|
| 43 | if (ierr == 0)
|
|---|
| 44 | sprintf(msg,"[No error] ");
|
|---|
| 45 |
|
|---|
| 46 | if (ierr & HYPRE_ERROR_GENERIC)
|
|---|
| 47 | sprintf(msg,"[Generic error] ");
|
|---|
| 48 |
|
|---|
| 49 | if (ierr & HYPRE_ERROR_MEMORY)
|
|---|
| 50 | sprintf(msg,"[Memory error] ");
|
|---|
| 51 |
|
|---|
| 52 | if (ierr & HYPRE_ERROR_ARG)
|
|---|
| 53 | sprintf(msg,"[Error in argument %d] ", HYPRE_GetErrorArg());
|
|---|
| 54 |
|
|---|
| 55 | if (ierr & HYPRE_ERROR_CONV)
|
|---|
| 56 | sprintf(msg,"[Method did not converge] ");
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | int HYPRE_GetErrorArg()
|
|---|
| 60 | {
|
|---|
| 61 | return (hypre_error_flag>>3 & 31);
|
|---|
| 62 | }
|
|---|