Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added callct2 utility function to handle all string outputs
- Loading branch information
Showing
6 changed files
with
46 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,17 @@ | ||
function output = callct(varargin) | ||
% CALLCT | ||
% This is a simplified single output variant | ||
% Calls Cantera library functions with single outputs and returns | ||
% errors if necessary. | ||
|
||
err1 = -1; | ||
err2 = -999.999; | ||
err3 = double(intmax('uint64')); | ||
|
||
methodname = varargin{1}; | ||
output = calllib(ct, methodname, varargin{2:end}); | ||
output = calllib(ct, varargin); | ||
if output == err2 || output == err3 | ||
output = -1; | ||
output = err1; | ||
end | ||
if output == -1 | ||
geterr; | ||
if output == err1 | ||
error(geterr); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function output = callct2(varargin) | ||
% CALLCT2 | ||
% Calls Cantera library functions with string outputs and returns | ||
% errors if necessary. | ||
|
||
err1 = -1; | ||
|
||
buflen = calllib(ct, varargin, 0, ''); | ||
if buflen > 0 | ||
aa = char(ones(1, buflen)); | ||
ptr = libpointer('cstring', aa); | ||
[iok, bb] = calllib(ct, varargin, buflen, ptr); | ||
output = bb; | ||
clear aa bb ptr; | ||
else | ||
error(geterr); | ||
end | ||
if iok == -err1 | ||
error(geterr); | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters