Amesos Package Browser (Single Doxygen Collection) Development
amesos_cholmod_error.c
Go to the documentation of this file.
00001 /* ========================================================================== */
00002 /* === Core/cholmod_error =================================================== */
00003 /* ========================================================================== */
00004 
00005 /* -----------------------------------------------------------------------------
00006  * CHOLMOD/Core Module.  Copyright (C) 2005-2006,
00007  * Univ. of Florida.  Author: Timothy A. Davis
00008  * The CHOLMOD/Core Module is licensed under Version 2.1 of the GNU
00009  * Lesser General Public License.  See lesser.txt for a text of the license.
00010  * CHOLMOD is also available under other licenses; contact authors for details.
00011  * http://www.cise.ufl.edu/research/sparse
00012  * -------------------------------------------------------------------------- */
00013 
00014 /* CHOLMOD error-handling routine.  */
00015 
00016 #include "amesos_cholmod_internal.h"
00017 #include "amesos_cholmod_core.h"
00018 
00019 /* ========================================================================== */
00020 /* ==== cholmod_error ======================================================= */
00021 /* ========================================================================== */
00022 
00023 /* An error has occurred.  Set the status, optionally print an error message,
00024  * and call the user error-handling routine (if it exists).  If
00025  * Common->try_catch is TRUE, then CHOLMOD is inside a try/catch block.
00026  * The status is set, but no message is printed and the user error handler
00027  * is not called.  This is not (yet) an error, since CHOLMOD may recover.
00028  *
00029  * In the current version, this try/catch mechanism is used internally only in
00030  * cholmod_analyze, which tries multiple ordering methods and picks the best
00031  * one.  If one or more ordering method fails, it keeps going.  Only one
00032  * ordering needs to succeed for cholmod_analyze to succeed.
00033  */
00034 
00035 int CHOLMOD(error)
00036 (
00037     /* ---- input ---- */
00038     int status,   /* error status */
00039     char *file,   /* name of source code file where error occured */ 
00040     int line,   /* line number in source code file where error occured*/
00041     char *message,  /* error message */
00042     /* --------------- */
00043     cholmod_common *Common
00044 )
00045 {
00046     RETURN_IF_NULL_COMMON (FALSE) ;
00047 
00048     Common->status = status ;
00049 
00050     if (!(Common->try_catch))
00051     {
00052 
00053 #ifndef NPRINT
00054   /* print a warning or error message */
00055   if (Common->print_function != NULL)
00056   {
00057       if (status > 0 && Common->print > 1)
00058       {
00059     (Common->print_function) ("CHOLMOD warning: %s\n", message) ;
00060     fflush (stdout) ;
00061     fflush (stderr) ;
00062       }
00063       else if (Common->print > 0)
00064       {
00065     (Common->print_function) ("CHOLMOD error: %s\n", message) ;
00066     fflush (stdout) ;
00067     fflush (stderr) ;
00068       }
00069   }
00070 #endif
00071 
00072   /* call the user error handler, if it exists */
00073   if (Common->error_handler != NULL)
00074   {
00075       Common->error_handler (status, file, line, message) ;
00076   }
00077     }
00078 
00079     return (TRUE) ;
00080 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines