diff --git a/packages/seacas/libraries/exodus/src/ex_err.c b/packages/seacas/libraries/exodus/src/ex_err.c index 2f7ba269fe..68cf7b395a 100644 --- a/packages/seacas/libraries/exodus/src/ex_err.c +++ b/packages/seacas/libraries/exodus/src/ex_err.c @@ -9,42 +9,62 @@ #include "exodusII.h" // for exoptval, MAX_ERR_LENGTH, etc #include "exodusII_int.h" +#if defined(EXODUS_THREADSAFE) +EX_errval_t *ex_errval = NULL; +#define EX_PNAME ex_errval->last_pname +#define EX_ERRMSG ex_errval->last_errmsg +#define EX_ERR_NUM ex_errval->last_err_num +#else +int exerrval = 0; /* clear initial global error code value */ + +static char last_pname[MAX_ERR_LENGTH + 1]; +static char last_errmsg[MAX_ERR_LENGTH + 1]; +static int last_err_num; + +#define EX_PNAME last_pname +#define EX_ERRMSG last_errmsg +#define EX_ERR_NUM last_err_num +#endif + /*! -\ingroup Utilities -\fn{void ex_err_fn(exoid, const char *module_name, const char *message, int err_num)} + \ingroup Utilities + \undoc +*/ +void ex__reset_error_status(void) +{ +#if !defined(EXODUS_THREADSAFE) + exerrval = 0; + EX_ERR_NUM = 0; +#endif +} -The function ex_err_fn(exoid, ) logs an error to stderr. It is intended +/*! +\ingroup Utilities +The function ex_err(exoid, ...) logs an error to stderr. It is intended to provide explanatory messages for error codes returned from other exodus routines. The passed in error codes and corresponding messages are listed in -???. The programmer may supplement the error message printed +\file{exodusII.h}. The programmer may supplement the error message printed for standard errors by providing an error message. If the error code is provided with no error message, the predefined message will be -used. The error code EX_MSG is available to log application +used. The error code \c EX_MSG is available to log application specific messages. -\param[in] module_name This is a string containing the name of the calling -function. -\param[in] message This is a string containing a message explaining the -error - or problem. If EX_VERBOSE (see ex_opts()) is true, +\param[in] module_name This is a string containing the name of the calling function. +\param[in] message This is a string containing a message explaining the error + or problem. If \c EX_VERBOSE (see ex_opts()) is true, this message will be printed to stderr. Otherwise, - nothing will be printed. Maximum length is \c -MAX_ERR_LENGTH. + nothing will be printed. Maximum length is \c MAX_ERR_LENGTH. \param[in] err_num This is an integer code identifying the error. exodus C -functions - place an error code value in exerrval, an external -int. Negative - values are considered fatal errors while positive -values are - warnings. There is a set of predefined values defined -in - \file{exodusII.h}. The predefined constant \c -EX_PRTLASTMSG will - cause the last error message to be output, regardless -of the setting + functions place an error code value in exerrval, + an external integer. Negative values are considered + fatal errors while positive values are warnings. + There is a set of predefined values defined in + \file{exodusII.h}. The predefined constant + \c EX_PRTLASTMSG will cause the last error message + to be output, regardless of the setting of the error reporting level (see ex_opts()). The following is an example of the use of this function: @@ -62,45 +82,11 @@ if (exoid = ex_open ("test.exo", EX_READ, &CPU_word_size, &IO_word_size, &version)) { errval = 999; snprintf(errmsg, MAX_ERR_LENGTH,"ERROR: cannot open file test.exo"); - ex_err_fn(exoid, __func__, errmsg, errval); + ex_err(__func__, errmsg, errval); } ~~~ */ - -#if defined(EXODUS_THREADSAFE) -EX_errval_t *ex_errval = NULL; -#define EX_PNAME ex_errval->last_pname -#define EX_ERRMSG ex_errval->last_errmsg -#define EX_ERR_NUM ex_errval->last_err_num -#else -int exerrval = 0; /* clear initial global error code value */ - -static char last_pname[MAX_ERR_LENGTH + 1]; -static char last_errmsg[MAX_ERR_LENGTH + 1]; -static int last_err_num; - -#define EX_PNAME last_pname -#define EX_ERRMSG last_errmsg -#define EX_ERR_NUM last_err_num -#endif - -/*! - \ingroup Utilities - \undoc -*/ -void ex__reset_error_status(void) -{ -#if !defined(EXODUS_THREADSAFE) - exerrval = 0; - EX_ERR_NUM = 0; -#endif -} - -/*! - \ingroup Utilities - \undoc -*/ void ex_err(const char *module_name, const char *message, int err_num) { EX_FUNC_ENTER_INT(); @@ -157,8 +143,55 @@ void ex_err(const char *module_name, const char *message, int err_num) } /*! - \ingroup Utilities - \undoc +\ingroup Utilities +The function ex_err_fn() logs an error to stderr. It is intended +to provide explanatory messages for error codes returned from other +exodus routines. The main difference between ex_err_fn() and ex_err() is +that ex_err_fn() will print the name of the exodus file that the error occured on. + +The passed in error codes and corresponding messages are listed in +\file{exodusII.h}. The programmer may supplement the error message printed +for standard errors by providing an error message. If the error code +is provided with no error message, the predefined message will be +used. The error code \c EX_MSG is available to log application +specific messages. + +\param[in] exoid exodus file ID returned from a previous call to ex_create() or ex_open(). +\param[in] module_name This is a string containing the name of the calling function. +\param[in] message This is a string containing a message explaining the error + or problem. If \c EX_VERBOSE (see ex_opts()) is true, + this message will be printed to stderr. Otherwise, + nothing will be printed. Maximum length is \c MAX_ERR_LENGTH. + +\param[in] err_num This is an integer code identifying the error. exodus C + functions place an error code value in exerrval, + an external integer. Negative values are considered + fatal errors while positive values are warnings. + There is a set of predefined values defined in + \file{exodusII.h}. The predefined constant + \c EX_PRTLASTMSG will cause the last error message + to be output, regardless of the setting + of the error reporting level (see ex_opts()). + +The following is an example of the use of this function: + +~~~{.c} +int exoid, CPU_word_size, IO_word_size, errval; +float version; +char errmsg[MAX_ERR_LENGTH]; + +CPU_word_size = sizeof(float); +IO_word_size = 0; + +\comment{open exodus file} +if (exoid = ex_open ("test.exo", EX_READ, &CPU_word_size, + &IO_word_size, &version)) { + errval = 999; + snprintf(errmsg, MAX_ERR_LENGTH,"ERROR: cannot open file test.exo"); + ex_err_fn(exoid, __func__, errmsg, errval); +} +~~~ + */ void ex_err_fn(int exoid, const char *module_name, const char *message, int err_num) {