[clib/Matlab] Add function for getting Cantera version

This commit is contained in:
Ray Speth
2016-11-08 13:34:48 -05:00
parent 583b715fca
commit 5641fa83e9
5 changed files with 30 additions and 1 deletions

View File

@@ -212,7 +212,8 @@ if localenv['sphinx_docs']:
'@Data': ['Air.m', 'constants.m', 'gasconstant.m', 'GRI30.m',
'Hydrogen.m', 'Methane.m', 'Nitrogen.m', 'oneatm.m',
'Oxygen.m', 'Water.m'],
'@Utilities': ['adddir.m', 'ck2cti.m', 'cleanup.m', 'geterr.m', 'getDataDirectories.m']
'@Utilities': ['adddir.m', 'ck2cti.m', 'cleanup.m', 'geterr.m',
'getDataDirectories.m', 'canteraVersion.m']
}
# These files do not need to be documented in the MATLAB classes because they

View File

@@ -156,6 +156,7 @@ extern "C" {
CANTERA_CAPI int ct_setLogWriter(void* logger);
CANTERA_CAPI int ct_addCanteraDirectory(size_t buflen, const char* buf);
CANTERA_CAPI int ct_getDataDirectories(int buflen, char* buf, const char* sep);
CANTERA_CAPI int ct_getCanteraVersion(int buflen, char* buf);
CANTERA_CAPI int ct_clearStorage();
CANTERA_CAPI int ct_ck2cti(const char* in_file, const char* db_file,

View File

@@ -0,0 +1,10 @@
function v = canteraVersion()
% CANTERAVERSION Get Cantera version information
% canteraVersion()
%
% :return:
% A string containing the Cantera version
%
v = ctmethods(0, 6);

View File

@@ -1419,6 +1419,15 @@ extern "C" {
}
}
int ct_getCanteraVersion(int buflen, char* buf)
{
try {
return copyString(CANTERA_VERSION, buf, buflen);
} catch (...) {
return handleAllExceptions(-1, ERR);
}
}
int ct_setLogWriter(void* logger)
{
try {

View File

@@ -90,6 +90,14 @@ void ctfunctions(int nlhs, mxArray* plhs[],
iok = 0;
return;
// get cantera version string
case 6:
buflen = ct_getCanteraVersion(0, 0);
output_buf = (char*)mxCalloc(buflen, sizeof(char));
iok = ct_getCanteraVersion(buflen, output_buf);
plhs[0] = mxCreateString(output_buf);
return;
default:
mexErrMsgTxt("ctfunctions: unknown job");
}