Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
amesos_cholmod_l_error.c
Go to the documentation of this file.
1 /* ========================================================================== */
2 /* === Core/cholmod_error =================================================== */
3 /* ========================================================================== */
4 
5 /* -----------------------------------------------------------------------------
6  * CHOLMOD/Core Module. Copyright (C) 2005-2006,
7  * Univ. of Florida. Author: Timothy A. Davis
8  * The CHOLMOD/Core Module is licensed under Version 2.1 of the GNU
9  * Lesser General Public License. See lesser.txt for a text of the license.
10  * CHOLMOD is also available under other licenses; contact authors for details.
11  * http://www.cise.ufl.edu/research/sparse
12  * -------------------------------------------------------------------------- */
13 
14 /* CHOLMOD error-handling routine. */
15 
16 /* This file should make the long int version of CHOLMOD */
17 #define DLONG 1
18 
20 #include "amesos_cholmod_core.h"
21 
22 /* ========================================================================== */
23 /* ==== cholmod_error ======================================================= */
24 /* ========================================================================== */
25 
26 /* An error has occurred. Set the status, optionally print an error message,
27  * and call the user error-handling routine (if it exists). If
28  * Common->try_catch is TRUE, then CHOLMOD is inside a try/catch block.
29  * The status is set, but no message is printed and the user error handler
30  * is not called. This is not (yet) an error, since CHOLMOD may recover.
31  *
32  * In the current version, this try/catch mechanism is used internally only in
33  * cholmod_analyze, which tries multiple ordering methods and picks the best
34  * one. If one or more ordering method fails, it keeps going. Only one
35  * ordering needs to succeed for cholmod_analyze to succeed.
36  */
37 
38 int CHOLMOD(error)
39 (
40  /* ---- input ---- */
41  int status, /* error status */
42  char *file, /* name of source code file where error occured */
43  int line, /* line number in source code file where error occured*/
44  char *message, /* error message */
45  /* --------------- */
46  cholmod_common *Common
47 )
48 {
50 
51  Common->status = status ;
52 
53  if (!(Common->try_catch))
54  {
55 
56 #ifndef NPRINT
57  /* print a warning or error message */
58  if (Common->print_function != NULL)
59  {
60  if (status > 0 && Common->print > 1)
61  {
62  (Common->print_function) ("CHOLMOD warning: %s\n", message) ;
63  fflush (stdout) ;
64  fflush (stderr) ;
65  }
66  else if (Common->print > 0)
67  {
68  (Common->print_function) ("CHOLMOD error: %s\n", message) ;
69  fflush (stdout) ;
70  fflush (stderr) ;
71  }
72  }
73 #endif
74 
75  /* call the user error handler, if it exists */
76  if (Common->error_handler != NULL)
77  {
78  Common->error_handler (status, file, line, message) ;
79  }
80  }
81 
82  return (TRUE) ;
83 }
#define FALSE
#define RETURN_IF_NULL_COMMON(result)
#define CHOLMOD(name)
#define NULL
int CHOLMOD() error(int status, char *file, int line, char *message, cholmod_common *Common)
#define TRUE