diff --git a/@SBMLode/importSBML.m b/@SBMLode/importSBML.m index 011247a022..d1a3191bbf 100644 --- a/@SBMLode/importSBML.m +++ b/@SBMLode/importSBML.m @@ -676,7 +676,7 @@ function checkIllegalFunctions(str) csym = sym(sanitizeString(strrep(str,'time','__time_internal_amici__'))); csym = subs(csym,sym('__time_internal_amici__'),sym('time')); else - csym = sym(); + csym = sym(0); end end diff --git a/@amimodel/compileC.m b/@amimodel/compileC.m index 9416c2fb42..0498438535 100644 --- a/@amimodel/compileC.m +++ b/@amimodel/compileC.m @@ -405,16 +405,7 @@ function compileC(this) fprintf('amici | '); - if(this.nxtrue ~= this.nx) - cstr = 'amicio2.cpp'; - else - cstr = 'amici.cpp'; - end - eval(['mex ' DEBUG COPT ... - ' -c -outdir ' fullfile(this.wrap_path,'src') ' ' ... - fullfile(this.wrap_path,'src',cstr) ' ' ... - includesstr]); - + if(isunix) if(~ismac) CLIBS = 'CLIBS="-lrt"'; @@ -429,37 +420,37 @@ function compileC(this) end end - - if(this.nxtrue ~= this.nx) - cstr = 'amiwrapo2.cpp'; - o2ext = 'o2'; - else - cstr = 'amiwrap.cpp'; - o2ext = ''; + if(this.nxtrue == this.nx) + eval(['mex ' DEBUG COPT ... + ' -c -outdir ' fullfile(this.wrap_path,'src') ' ' ... + fullfile(this.wrap_path,'src','amici.cpp') ' ' ... + includesstr]); end - - prefix = 'ami'; - - eval(['mex ' DEBUG ' ' COPT ... - ' -c -outdir ' fullfile(this.wrap_path,'src') ' ' ... - fullfile(this.wrap_path,'src',cstr) ' ' ... - includesstr]); + if(this.nxtrue == this.nx) + eval(['mex ' DEBUG ' ' COPT ... + ' -c -outdir ' fullfile(this.wrap_path,'src') ' ' ... + fullfile(this.wrap_path,'src','amiwrap.cpp') ' ' ... + includesstr]); + end - eval(['mex ' DEBUG ' ' COPT ... - ' -c -outdir ' fullfile(this.wrap_path,'src') ' ' ... - fullfile(this.wrap_path,'src','amici_interface_matlab.cpp') ' ' ... - includesstr]); + if(this.nxtrue == this.nx) + eval(['mex ' DEBUG ' ' COPT ... + ' -c -outdir ' fullfile(this.wrap_path,'src') ' ' ... + fullfile(this.wrap_path,'src','amici_interface_matlab.cpp') ' ' ... + includesstr]); + end eval(['mex ' DEBUG ' ' COPT ' ' CLIBS ... - ' -output ' fullfile(this.wrap_path,'models',this.modelname,[prefix '_' this.modelname]) ... - ' "' fullfile(this.wrap_path,'src',['amiwrap' o2ext o_suffix]) '"' ... - ' "' fullfile(this.wrap_path,'src',['amici' o2ext o_suffix]) '"' ... - ' "' fullfile(this.wrap_path,'src',['amici_interface_matlab' o2ext o_suffix]) '"' ... + ' -output ' fullfile(this.wrap_path,'models',this.modelname,['ami_' this.modelname]) ... + ' "' fullfile(this.wrap_path,'src',['amiwrap' o_suffix]) '"' ... + ' "' fullfile(this.wrap_path,'src',['amici' o_suffix]) '"' ... + ' "' fullfile(this.wrap_path,'src',['amici_interface_matlab' o_suffix]) '"' ... ' "' fullfile(this.wrap_path,'models',this.modelname,['wrapfunctions' o_suffix]) '"' ... objectsstr ... includesstr ... ]) + diff --git a/include/amici.h b/include/amici.h index 17a3fb2ff7..343a3d662e 100644 --- a/include/amici.h +++ b/include/amici.h @@ -30,6 +30,8 @@ void runAmiciSimulation(UserData *udata, const ExpData *edata, ReturnData *rdata, int *pstatus); +void invalidateReturnData(UserData* udata, ReturnData* rdata); + void *setupAMI(int *status, UserData *udata, TempData *tdata); void setupAMIB(int *status, void *ami_mem, UserData *udata, TempData *tdata); diff --git a/src/amici.cpp b/src/amici.cpp index 98c086a6a1..51ad0b8340 100644 --- a/src/amici.cpp +++ b/src/amici.cpp @@ -64,9 +64,28 @@ void runAmiciSimulation(UserData *udata, const ExpData *edata, ReturnData *rdata applyChainRuleFactorToSimulationResults(udata, rdata, edata); freturn: + if(*pstatus<0){ + invalidateReturnData(udata, rdata); + } freeTempDataAmiMem(udata, tdata, ami_mem, setupBdone, *pstatus); } +void invalidateReturnData(UserData* udata, ReturnData* rdata) { + /** + * @brief performs all necessary actions to reset return data upon integration failure + * @param[in] udata pointer to the user data struct @type UserData + * @param[out] rdata pointer to the return data struct @type ReturnData + */ + if(llhdata) + *llhdata = amiGetNaN(); + + if(sllhdata) + fillArray(sllhdata, nplist, amiGetNaN()); + + if(s2llhdata) + fillArray(s2llhdata, nplist*(ng-1), amiGetNaN()); +} + void *setupAMI(int *status, UserData *udata, TempData *tdata) { /** * @brief setupAMIs initialises the ami memory object diff --git a/src/amicio2.cpp b/src/amicio2.cpp deleted file mode 100644 index bed1d75b4a..0000000000 --- a/src/amicio2.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "amici.cpp" \ No newline at end of file diff --git a/src/amiwrapo2.cpp b/src/amiwrapo2.cpp deleted file mode 100644 index 75ee176b26..0000000000 --- a/src/amiwrapo2.cpp +++ /dev/null @@ -1 +0,0 @@ -#include "amiwrap.cpp" \ No newline at end of file