TECA
The Toolkit for Extreme Climate Analysis
teca_common.h File Reference
#include "teca_config.h"
#include "teca_parallel_id.h"
#include <iostream>
#include <sstream>
#include <unistd.h>
#include <cstdio>
#include <string>
#include <vector>
Include dependency graph for teca_common.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 teca_error
 global error handling hooks
 

Macros

#define TECA_MESSAGE(_strm, _head, _head_color, _msg)
 
#define TECA_MESSAGE_RAW(_strm, _head, _msg)
 Send a message into the stream that include MPI ranks and thread id. More...
 
#define TECA_FATAL_ERROR(_msg)
 
#define TECA_ERROR(_msg)   TECA_MESSAGE(std::cerr, "ERROR:", ANSI_RED, _msg)
 Constructs an error message and sends it to the stderr stream. More...
 
#define TECA_WARNING(_msg)   TECA_MESSAGE(std::cerr, "WARNING:", ANSI_YELLOW, _msg)
 Constructs a warning message and sends it to the stderr stream. More...
 
#define TECA_STATUS(_msg)   TECA_MESSAGE(std::cerr, "STATUS:", ANSI_GREEN, _msg)
 Constructs a status message and sends it to the stderr stream. More...
 

Typedefs

using p_teca_error_handler = void(*)(const char *)
 

Functions

void teca_error::error_message (const char *msg)
 
void teca_error::error_message_abort (const char *msg)
 
void teca_error::set_error_handler (p_teca_error_handler handler)
 
void teca_error::set_error_message_handler ()
 Install the teca_error::error_message error handler. More...
 
void teca_error::set_error_message_abort_handler ()
 Install the teca_error::error_message_abort error handler. More...
 

Variables

p_teca_error_handler teca_error::error_handler
 The global error handler instance. More...
 

Macro Definition Documentation

◆ TECA_ERROR

#define TECA_ERROR (   _msg)    TECA_MESSAGE(std::cerr, "ERROR:", ANSI_RED, _msg)

Constructs an error message and sends it to the stderr stream.

◆ TECA_FATAL_ERROR

#define TECA_FATAL_ERROR (   _msg)
Value:
{ \
std::ostringstream ess; \
TECA_MESSAGE(ess, "ERROR:", ANSI_RED, _msg) \
teca_error::error_handler(ess.str().c_str()); \
}

Constructs an the error message using TECA_MESSAGE and invokes the error handler.

◆ TECA_MESSAGE

#define TECA_MESSAGE (   _strm,
  _head,
  _head_color,
  _msg 
)
Value:
_strm \
<< BEGIN_HL(_head_color) << _head << END_HL \
<< " " << teca_parallel_id() << " [" << __FILE__ << ":" << __LINE__ \
<< " " << TECA_VERSION_DESCR << "]" << std::endl \
<< BEGIN_HL(_head_color) << _head << END_HL << " " \
<< BEGIN_HL(ANSI_WHITE) << "" _msg << END_HL << std::endl;

Send a message into the stream with an ANSI color coded message that include MPI ranks and thread id.

◆ TECA_MESSAGE_RAW

#define TECA_MESSAGE_RAW (   _strm,
  _head,
  _msg 
)
Value:
_strm \
<< _head << " " << teca_parallel_id() << " [" << __FILE__ \
<< ":" << __LINE__ << " " << TECA_VERSION_DESCR << "]" << std::endl \
<< _head << " " << "" _msg << std::endl;

Send a message into the stream that include MPI ranks and thread id.

◆ TECA_STATUS

#define TECA_STATUS (   _msg)    TECA_MESSAGE(std::cerr, "STATUS:", ANSI_GREEN, _msg)

Constructs a status message and sends it to the stderr stream.

◆ TECA_WARNING

#define TECA_WARNING (   _msg)    TECA_MESSAGE(std::cerr, "WARNING:", ANSI_YELLOW, _msg)

Constructs a warning message and sends it to the stderr stream.

Typedef Documentation

◆ p_teca_error_handler

using p_teca_error_handler = void (*) (const char*)

The call signature for the error handler. The error handler will be passed a string describing the error.

teca_error::error_handler
p_teca_error_handler error_handler
The global error handler instance.
teca_parallel_id
A helper class for debug and error messages.
Definition: teca_parallel_id.h:9