Fixed some problems printing error messages in Matlab
This commit is contained in:
parent
8799001ee3
commit
32de9a8b27
6 changed files with 10 additions and 33 deletions
|
|
@ -34,7 +34,8 @@ end
|
|||
|
||||
% Set path to Python module
|
||||
setenv('PYTHONPATH', fullfile(cantera_root, 'interfaces', 'python'))
|
||||
setenv('CANTERA_DATA', fullfile(cantera_root, 'data', 'inputs'))
|
||||
|
||||
% A simple test to make sure that the ctmethods.mex file is present and working
|
||||
f = Func('polynomial', 3, [1,2,3,4])
|
||||
|
||||
adddir(fullfile(cantera_root, 'data', 'inputs'))
|
||||
|
|
|
|||
|
|
@ -403,7 +403,7 @@ extern "C" {
|
|||
|
||||
//-------------- Thermo --------------------//
|
||||
|
||||
size_t newThermoFromXML(int mxml)
|
||||
int newThermoFromXML(int mxml)
|
||||
{
|
||||
try {
|
||||
XML_Node& x = XmlCabinet::item(mxml);
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ extern "C" {
|
|||
double charge, double weight);
|
||||
|
||||
//int newThermo(char* model);
|
||||
CANTERA_CAPI size_t newThermoFromXML(int mxml);
|
||||
CANTERA_CAPI int newThermoFromXML(int mxml);
|
||||
CANTERA_CAPI int th_thermoIndex(char* id);
|
||||
CANTERA_CAPI int th_phase(int n);
|
||||
CANTERA_CAPI size_t th_nSpecies(size_t n);
|
||||
|
|
|
|||
|
|
@ -28,8 +28,8 @@ void ctfunctions(int nlhs, mxArray* plhs[],
|
|||
int job = getInt(prhs[1]);
|
||||
int iok, dbg, validate;
|
||||
char* infile, *dbfile, *trfile, *idtag;
|
||||
int buflen;
|
||||
char* output_buf;
|
||||
int buflen = 0;
|
||||
char* output_buf = 0;
|
||||
|
||||
switch (job) {
|
||||
|
||||
|
|
@ -50,7 +50,7 @@ void ctfunctions(int nlhs, mxArray* plhs[],
|
|||
|
||||
// get Cantera error
|
||||
case 2:
|
||||
buflen = 300;
|
||||
buflen = getCanteraError(buflen, output_buf) + 1;
|
||||
output_buf = (char*)mxCalloc(buflen, sizeof(char));
|
||||
iok = getCanteraError(buflen, output_buf);
|
||||
plhs[0] = mxCreateString(output_buf);
|
||||
|
|
|
|||
|
|
@ -79,8 +79,7 @@ void initLogger()
|
|||
if (!_logger) {
|
||||
_logger = new Cantera::ML_Logger;
|
||||
// Call the DLL program to set the logger
|
||||
void* vl = (void*) _logger;
|
||||
int retn = setLogWriter(vl);
|
||||
int retn = setLogWriter(_logger);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,10 +7,6 @@
|
|||
#include "ctmatutils.h"
|
||||
#include "cantera/base/logger.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
static std::string ss = "disp(' ";
|
||||
|
||||
namespace Cantera
|
||||
{
|
||||
|
||||
|
|
@ -20,25 +16,8 @@ public:
|
|||
ML_Logger() {}
|
||||
virtual ~ML_Logger() {}
|
||||
|
||||
|
||||
virtual void write(const std::string& s) {
|
||||
char ch = s[0];
|
||||
int n = 0;
|
||||
while (ch != '\0') {
|
||||
if (ch =='\n') {
|
||||
ss += "');";
|
||||
|
||||
mexEvalString(ss.c_str());
|
||||
ss = "disp(' ";
|
||||
} else {
|
||||
ss += ch;
|
||||
}
|
||||
if (ch == '\'') {
|
||||
ss += ch;
|
||||
}
|
||||
n++;
|
||||
ch = s[n];
|
||||
}
|
||||
mexPrintf("%s", s.c_str());
|
||||
}
|
||||
|
||||
virtual void writeendl(const std::string& msg) {
|
||||
|
|
@ -46,9 +25,7 @@ public:
|
|||
}
|
||||
|
||||
virtual void error(const std::string& msg) {
|
||||
std::string err = "error("+msg+");";
|
||||
//mexEvalString(err.c_str());
|
||||
mexErrMsgTxt(err.c_str());
|
||||
mexErrMsgTxt(msg.c_str());
|
||||
}
|
||||
|
||||
DEPRECATED(virtual int env()) {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue