diff --git a/interfaces/matlab/testpath.m b/interfaces/matlab/testpath.m index 7b90a512b..1f16b0f03 100644 --- a/interfaces/matlab/testpath.m +++ b/interfaces/matlab/testpath.m @@ -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')) diff --git a/src/clib/ct.cpp b/src/clib/ct.cpp index 2a08ea044..84e420ff9 100644 --- a/src/clib/ct.cpp +++ b/src/clib/ct.cpp @@ -403,7 +403,7 @@ extern "C" { //-------------- Thermo --------------------// - size_t newThermoFromXML(int mxml) + int newThermoFromXML(int mxml) { try { XML_Node& x = XmlCabinet::item(mxml); diff --git a/src/clib/ct.h b/src/clib/ct.h index 5db664d60..59b7b7ca1 100644 --- a/src/clib/ct.h +++ b/src/clib/ct.h @@ -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); diff --git a/src/matlab/ctfunctions.cpp b/src/matlab/ctfunctions.cpp index f56326e2f..61d2c31b9 100644 --- a/src/matlab/ctfunctions.cpp +++ b/src/matlab/ctfunctions.cpp @@ -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); diff --git a/src/matlab/ctmethods.cpp b/src/matlab/ctmethods.cpp index 7ab6c8191..47a50824b 100644 --- a/src/matlab/ctmethods.cpp +++ b/src/matlab/ctmethods.cpp @@ -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); } } diff --git a/src/matlab/mllogger.h b/src/matlab/mllogger.h index e2016c7b8..6669ca646 100644 --- a/src/matlab/mllogger.h +++ b/src/matlab/mllogger.h @@ -7,10 +7,6 @@ #include "ctmatutils.h" #include "cantera/base/logger.h" -#include - -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()) {