Skip to content

Commit

Permalink
[clib/Matlab] Add function for getting Cantera version
Browse files Browse the repository at this point in the history
  • Loading branch information
speth committed Nov 12, 2016
1 parent 583b715 commit 5641fa8
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 1 deletion.
3 changes: 2 additions & 1 deletion doc/SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions include/cantera/clib/ct.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 10 additions & 0 deletions interfaces/matlab/toolbox/canteraVersion.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
function v = canteraVersion()
% CANTERAVERSION Get Cantera version information
% canteraVersion()
%
% :return:
% A string containing the Cantera version
%

v = ctmethods(0, 6);

9 changes: 9 additions & 0 deletions src/clib/ct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions src/matlab/ctfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 5641fa8

Please sign in to comment.