Got rid of the matlab write.cpp routine. It was causing linking problems
on the pc. Cleaned up the comments on loggers and interfaces.
This commit is contained in:
parent
60c6fd5c28
commit
0badf5e19c
6 changed files with 48 additions and 112 deletions
|
|
@ -1,56 +0,0 @@
|
|||
/**
|
||||
* @file cxx/src/writelog.cpp
|
||||
*/
|
||||
|
||||
/*
|
||||
* $Author$
|
||||
* $Revision$
|
||||
* $Date$
|
||||
*/
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
//using namespace std;
|
||||
|
||||
namespace Cantera_CXX {
|
||||
/**
|
||||
*
|
||||
* writelog():
|
||||
*
|
||||
* Write a diagnostic message to standard output.
|
||||
* -> defined in global.h
|
||||
*
|
||||
* There are several versions of function writelog, each designed
|
||||
* for a particular environment. One version is designed for use
|
||||
* in C++ programs, or in any environment where messages can be
|
||||
* written to the standard output stream. Other versions are
|
||||
* written specifically for Matlab and for Python, which call
|
||||
* Matlab or Python functions, respectively, to display the
|
||||
* message. This is particularly important for Matlab, since
|
||||
* everything written to the standard output simply
|
||||
* disappears. For Python, the messages show up, but are not in
|
||||
* the right order if Python scripts also print output. Hence the
|
||||
* need for separate versions.
|
||||
*
|
||||
* The C++ version may be linked to an application by linking in
|
||||
* the library libctcxx.a (-lctcxx). The Python and Matlab
|
||||
* interfaces do not link this library, and instead link to their
|
||||
* own versions of writelog.
|
||||
*/
|
||||
void writelog(const string& s) {
|
||||
std::cout << s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write an error message and quit.
|
||||
*/
|
||||
void error(const std::string& msg) {
|
||||
std::cerr << msg << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
int userInterface() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -24,8 +24,7 @@ SRCS = cantera/private/ctmethods.cpp \
|
|||
cantera/private/flowdevicemethods.cpp \
|
||||
cantera/private/onedimmethods.cpp \
|
||||
cantera/private/surfmethods.cpp \
|
||||
cantera/private/funcmethods.cpp \
|
||||
cantera/private/write.cpp
|
||||
cantera/private/funcmethods.cpp
|
||||
|
||||
|
||||
CANTERA_LIBDIR=@buildlib@
|
||||
|
|
|
|||
|
|
@ -1,38 +0,0 @@
|
|||
|
||||
#include "mex.h"
|
||||
#include <string>
|
||||
|
||||
static std::string ss = "disp('";
|
||||
|
||||
namespace Cantera {
|
||||
|
||||
void writelog(const std::string& s) {
|
||||
// debug
|
||||
mexEvalString(s.c_str());
|
||||
// end debug
|
||||
char ch = s[0];
|
||||
int n = 0;
|
||||
while (ch != '\0') {
|
||||
if (ch =='\n') {
|
||||
ss += " ');";
|
||||
mexEvalString(ss.c_str());
|
||||
ss = "disp('doda: ";
|
||||
}
|
||||
else
|
||||
ss += ch;
|
||||
if (ch == '\'') ss += ch;
|
||||
n++;
|
||||
ch = s[n];
|
||||
}
|
||||
}
|
||||
|
||||
void error(const std::string& msg) {
|
||||
std::string err = "error("+msg+");";
|
||||
mexEvalString(err.c_str());
|
||||
}
|
||||
|
||||
int userInterface() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -99,7 +99,7 @@ extern "C" {
|
|||
|
||||
/* Add some symbolic constants to the module */
|
||||
d = PyModule_GetDict(m);
|
||||
ErrorObject = PyErr_NewException("cantera.error", NULL, NULL);
|
||||
ErrorObject = PyErr_NewException((char *)"cantera.error", NULL, NULL);
|
||||
PyDict_SetItemString(d, "error", ErrorObject);
|
||||
#ifdef HAS_NUMERIC
|
||||
PyDict_SetItemString(d, "nummod",PyString_FromString("Numeric"));
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
/**
|
||||
* @file global.h
|
||||
* This file contains definitions for utility functions and text for modules,
|
||||
* inputfiles, logs, textlogs, HTML_logs (see \ref inputfiles, \ref logs, \ref textlogs and \ref HTML_logs).
|
||||
* inputfiles, logs, textlogs, HTML_logs (see \ref inputfiles, \ref logs,
|
||||
* \ref textlogs and \ref HTML_logs).
|
||||
*
|
||||
* @ingroup utils
|
||||
*
|
||||
|
|
@ -61,8 +62,8 @@ namespace Cantera {
|
|||
|
||||
//! Prints all of the error messages to an ostream
|
||||
/*!
|
||||
* Print all of the error messages using function writelog.
|
||||
* Write out all of the saved error messages to the ostream f
|
||||
* using the member function writelog of class logger.
|
||||
* Cantera saves a stack of exceptions that it
|
||||
* has caught in the Application class. This routine writes
|
||||
* out all of the error messages to the ostream
|
||||
|
|
@ -74,14 +75,16 @@ namespace Cantera {
|
|||
*/
|
||||
void showErrors(std::ostream& f);
|
||||
|
||||
//! Print all of the error messages using function writelog.
|
||||
//! Print all of the error messages using function writelog of class logger.
|
||||
/*!
|
||||
* Print all of the error messages using function writelog.
|
||||
* Print all of the error messages
|
||||
* using the member function writelog of class logger.
|
||||
* Write out all of the saved error messages to the log device.
|
||||
* Cantera saves a stack of exceptions that it
|
||||
* has caught in the Application class. This routine writes
|
||||
* out all of the error messages to the log, usually stdout,
|
||||
* and then clears them from internal storage.
|
||||
* and then clears them from internal storage.
|
||||
*
|
||||
* \ingroup errorhandling
|
||||
*/
|
||||
void showErrors();
|
||||
|
|
@ -274,27 +277,39 @@ namespace Cantera {
|
|||
* is used from MATLAB or other application that do not have a
|
||||
* standard output stream.
|
||||
*
|
||||
* This routine is part of the interface suite whose behavior changes
|
||||
* with the interface. The interface suite has been moved to the
|
||||
* class logger and inherited classes of logger.
|
||||
*
|
||||
* @param msg String message to be written to the screen
|
||||
* @ingroup textlogs
|
||||
*/
|
||||
void writelog(const std::string& msg);
|
||||
|
||||
|
||||
//! Write a message to the screen.
|
||||
/*!
|
||||
* The string may be of any
|
||||
* length, and may contain end-of-line characters. This method is
|
||||
* used throughout %Cantera to write log messages.
|
||||
*
|
||||
* This routine is part of the interface suite whose behavior changes
|
||||
* with the interface. The interface suite has been moved to the
|
||||
* class logger and inherited classes of logger.
|
||||
*
|
||||
* @param msg c character string to be written to the screen
|
||||
* @ingroup textlogs
|
||||
*/
|
||||
void writelog(const char* msg);
|
||||
|
||||
|
||||
//! Write a formatted message to the screen
|
||||
/*!
|
||||
* Using the printf formatting of C, write a message to the screen
|
||||
* with variable values.
|
||||
*
|
||||
* Here, we format an internal string with the correct values
|
||||
* and then feed it into writelog().
|
||||
*
|
||||
* @param fmt c format string for the following arguments
|
||||
* @ingroup textlogs
|
||||
*/
|
||||
|
|
@ -309,6 +324,10 @@ namespace Cantera {
|
|||
|
||||
//! Write an error message and terminate execution.
|
||||
/*!
|
||||
* This routine is part of the interface suite whose behavior changes
|
||||
* with the interface. The interface suite has been moved to the
|
||||
* class logger and inherited classes of logger.
|
||||
*
|
||||
* @param msg Error message to be written to the screen.
|
||||
* @ingroup textlogs
|
||||
*/
|
||||
|
|
@ -316,6 +335,10 @@ namespace Cantera {
|
|||
|
||||
//! returns 1 for MATLAB, 2 for Python, and 0 for C++ or Fortran.
|
||||
/*!
|
||||
* This routine is part of the interface suite whose behavior changes
|
||||
* with the interface. The interface suite has been moved to the
|
||||
* class logger and inherited classes of logger.
|
||||
*
|
||||
* @ingroup textlogs
|
||||
*/
|
||||
int userInterface();
|
||||
|
|
@ -331,7 +354,8 @@ namespace Cantera {
|
|||
*/
|
||||
void setLogger(Logger* logwriter);
|
||||
|
||||
/// Return the conversion factor to convert unit std::string 'unit' to SI units.
|
||||
//! Return the conversion factor to convert unit std::string 'unit'
|
||||
//! to SI units.
|
||||
/*!
|
||||
* @param unit String containing the units
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -587,7 +587,7 @@ namespace Cantera {
|
|||
|
||||
//! Return the number of errors that have been encountered so far.
|
||||
/*!
|
||||
* @ingroup errorhandling
|
||||
* @ingroup error handling
|
||||
*/
|
||||
int getErrorCount() { return pMessenger->getErrorCount() ; }
|
||||
|
||||
|
|
@ -1509,19 +1509,26 @@ protected:
|
|||
// standard output stream. @ingroup textlogs
|
||||
|
||||
// Write a message to the screen
|
||||
void writelog(const std::string& msg) {
|
||||
app()->writelog(msg);
|
||||
}
|
||||
void writelog(const std::string& msg) {
|
||||
app()->writelog(msg);
|
||||
}
|
||||
|
||||
void writelogAM(const std::string& msg) {
|
||||
app()->writelog(msg);
|
||||
}
|
||||
|
||||
// Write a message to the screen
|
||||
void Application::Messages::writelog(const std::string& msg) {
|
||||
logwriter->write(msg) ;
|
||||
logwriter->write(msg);
|
||||
}
|
||||
|
||||
// Write a message to the screen.
|
||||
void writelog(const char* msg) {
|
||||
app()->writelog(msg);
|
||||
}
|
||||
void writelogAM(const char* msg) {
|
||||
app()->writelog(msg);
|
||||
}
|
||||
|
||||
// Write a message to the screen
|
||||
void Application::Messages::writelog(const char* pszmsg) {
|
||||
|
|
@ -1569,9 +1576,9 @@ protected:
|
|||
}
|
||||
|
||||
// @ingroup textlogs
|
||||
int userInterface() {
|
||||
return app()->getUserEnv();
|
||||
}
|
||||
int userInterface() {
|
||||
return app()->getUserEnv();
|
||||
}
|
||||
|
||||
// Return an integer specifying the application environment.
|
||||
int Application::Messages::getUserEnv() {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue