Skip to content

Commit

Permalink
- changed output point type OPT_EMTPY to OPT_NONE
Browse files Browse the repository at this point in the history
- if outputFormat in mos-skript is set to "empty", no result file is created in the cpp simulation runtime anymore
  • Loading branch information
Marcus Walther committed Jul 8, 2015
1 parent 42f53d1 commit 026f2b4
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 48 deletions.
72 changes: 37 additions & 35 deletions Compiler/Template/CodegenCpp.tpl
Expand Up @@ -732,10 +732,11 @@ case SIMCODE(modelInfo = MODELINFO(__)) then

void <%lastIdentOfPath(modelInfo.name)%>WriteOutput::initialize()
{
_historyImpl->init();


_historyImpl->clear();
if(getGlobalSettings()->getOutputPointType()!= OPT_NONE)
{
_historyImpl->init();
_historyImpl->clear();
}
}
<%writeoutput(simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)%>
>>
Expand Down Expand Up @@ -1460,6 +1461,7 @@ template simulationMainRunScript(SimCode simCode ,Text& extraFuncs,Text& extraFu
let moLib = makefileParams.compileDir
let home = makefileParams.omhome
let execParameters = '-s <%start%> -e <%end%> -f <%stepsize%> -v <%intervals%> -y <%tol%> -i <%solver%> -r <%simulationLibDir(simulationCodeTarget(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%> -m <%moLib%> -R <%simulationResults(getRunningTestsuite(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>'
let outputParameter = if (stringEq(settings.outputFormat, "empty")) then "-O none" else ""
let fileNamePrefixx = fileNamePrefix

let libFolder =simulationLibDir(simulationCodeTarget(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)
Expand All @@ -1471,7 +1473,7 @@ template simulationMainRunScript(SimCode simCode ,Text& extraFuncs,Text& extraFu
<<
#!/bin/sh
<%preRunCommandLinux%>
<%execCommandLinux%> ./<%fileNamePrefixx%> <%execParameters%> $*
<%execCommandLinux%> ./<%fileNamePrefixx%> <%execParameters%> <%outputParameter%> $*
>>
case "win32"
case "win64" then
Expand All @@ -1480,7 +1482,7 @@ template simulationMainRunScript(SimCode simCode ,Text& extraFuncs,Text& extraFu
<%preRunCommandWindows%>
REM ::export PATH=<%libFolder%>:$PATH REPLACE C: with /C/
SET PATH=<%home%>/bin;<%libFolder%>;<%libPaths%>;%PATH%
<%moLib%>/<%fileNamePrefixx%>.exe <%execParameters%>
<%moLib%>/<%fileNamePrefixx%>.exe <%execParameters%> <%outputParameter%>
>>
end match
end match
Expand Down Expand Up @@ -1929,7 +1931,7 @@ case SIMCODE(modelInfo=MODELINFO(__), makefileParams=MAKEFILE_PARAMS(__), simula
opts["-r"] = "<%simulationLibDir(simulationCodeTarget(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>";
opts["-m"] = "<%moLib%>";
opts["-R"] = "<%simulationResults(getRunningTestsuite(),simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace)%>";

<%if (stringEq(settings.outputFormat, "empty")) then 'opts["-O"] = "none";' else ""%>
<%
match(getConfigString(PROFILING_LEVEL))
case("none") then '//no profiling used'
Expand Down Expand Up @@ -5909,41 +5911,41 @@ case SIMCODE(modelInfo = MODELINFO(__),simulationSettingsOpt = SOME(settings as
writeDerivativeVarsResultNames(varsnames);

<%
match settings.outputFormat case "mat"
then
<<
writeParametertNames(paramnames);
writeIntParameterNames(paramnames);
writeBoolParameterNames(paramnames);
writeAlgVarsResultDescription(vardescs);
writeDiscreteAlgVarsResultDescription(vardescs);
writeIntAlgVarsResultDescription(vardescs);
writeBoolAlgVarsResultDescription(vardescs);
writeAliasVarsResultDescription(vardescs);
writeIntAliasVarsResultDescription(vardescs);
writeBoolAliasVarsResultDescription(vardescs);
writeStateVarsResultDescription(vardescs);
writeDerivativeVarsResultDescription(vardescs);
writeParameterDescription(paramdecs);
writeIntParameterDescription(paramdecs);
writeBoolParameterDescription(paramdecs);
>>
match settings.outputFormat
case "mat" then
<<
writeParametertNames(paramnames);
writeIntParameterNames(paramnames);
writeBoolParameterNames(paramnames);
writeAlgVarsResultDescription(vardescs);
writeDiscreteAlgVarsResultDescription(vardescs);
writeIntAlgVarsResultDescription(vardescs);
writeBoolAlgVarsResultDescription(vardescs);
writeAliasVarsResultDescription(vardescs);
writeIntAliasVarsResultDescription(vardescs);
writeBoolAliasVarsResultDescription(vardescs);
writeStateVarsResultDescription(vardescs);
writeDerivativeVarsResultDescription(vardescs);
writeParameterDescription(paramdecs);
writeIntParameterDescription(paramdecs);
writeBoolParameterDescription(paramdecs);
>>
%>
_historyImpl->write(varsnames,vardescs,paramnames,paramdecs);
<%
match settings.outputFormat case "mat"
then
<<
match settings.outputFormat
case "mat" then
<<
HistoryImplType::value_type_p params;

writeParams(params);
>>
else
<<
HistoryImplType::value_type_p params;
>>
>>
else
<<
HistoryImplType::value_type_p params;
>>
%>
_historyImpl->write(params,_global_settings->getStartTime(),_global_settings->getEndTime());
_historyImpl->write(params,_global_settings->getStartTime(),_global_settings->getEndTime());
}
//Write the current values
else
Expand Down
9 changes: 4 additions & 5 deletions Compiler/Template/CodegenCppHpcom.tpl
Expand Up @@ -702,17 +702,16 @@ template updateHpcom(list<SimEqSystem> allEquationsPlusWhen, list<SimWhenClause>

match simCode
case SIMCODE(modelInfo = MODELINFO(__), hpcomData=HPCOMDATA(__)) then
let parCode = generateParallelEvaluate(allEquationsPlusWhen, modelInfo.name, whenClauses, simCode, extraFuncs ,extraFuncsDecl, extraFuncsNamespace, hpcomData.schedules, context, stateDerVectorName, lastIdentOfPath(modelInfo.name), useFlatArrayNotation)
let &extraFuncsPar = buffer ""
let parCode = generateParallelEvaluate(allEquationsPlusWhen, modelInfo.name, whenClauses, simCode, extraFuncsPar ,extraFuncsDecl, extraFuncsNamespace, hpcomData.schedules, context, stateDerVectorName, lastIdentOfPath(modelInfo.name), useFlatArrayNotation)
<<
<%equationFunctions(allEquations,whenClauses, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, contextSimulationDiscrete,stateDerVectorName,useFlatArrayNotation,false)%>

<%createEvaluateConditions(allEquations,whenClauses, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, contextOther, stateDerVectorName, useFlatArrayNotation)%>
/*
<%createEvaluateZeroFuncs(equationsForZeroCrossings,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,contextOther)%>

<%createEvaluateAll(allEquations,whenClauses,simCode , &extraFuncs , &extraFuncsDecl, extraFuncsNamespace,contextOther, stateDerVectorName, useFlatArrayNotation, boolNot(stringEq(getConfigString(PROFILING_LEVEL),"none")))%>
*/
<%parCode%>

<%extraFuncsPar%>
>>
end match
end updateHpcom;
Expand Down
Expand Up @@ -111,7 +111,7 @@ void SolverDefaultImplementation::initialize()
timeevent_system->setTime(_tCurrent);


if(_settings->getGlobalSettings()->getOutputPointType() != OPT_EMPTY)
if(_settings->getGlobalSettings()->getOutputPointType() != OPT_NONE)
writeoutput_system->writeOutput(IWriteOutput::HEAD_LINE);

// Allocate array with values of zero functions
Expand Down Expand Up @@ -192,7 +192,7 @@ void SolverDefaultImplementation::writeToFile(const int& stp, const double& t, c
}
#endif

if(_settings->getGlobalSettings()->getOutputPointType()!= OPT_EMPTY)
if(_settings->getGlobalSettings()->getOutputPointType()!= OPT_NONE)
{
IWriteOutput* writeoutput_system = dynamic_cast<IWriteOutput*>(_system);

Expand Down
Expand Up @@ -27,7 +27,7 @@ using std::string;

enum LogCategory {LC_INIT = 0, LC_NLS = 1, LC_LS = 2, LC_SOLV = 3, LC_OUT = 4, LC_EVT = 5, LC_OTHER = 6, LC_MOD = 7};
enum LogLevel {LL_ERROR = 0, LL_WARNING = 1, LL_INFO = 2, LL_DEBUG = 3};
enum OutputPointType {OPT_ALL, OPT_STEP, OPT_EMPTY};
enum OutputPointType {OPT_ALL, OPT_STEP, OPT_NONE};

struct LogSettings
{
Expand Down
Expand Up @@ -57,7 +57,7 @@ SimSettings OMCFactory::readSimulationParameter(int argc, const char* argv[])
int portnum;
std::map<std::string,LogCategory> logCatMap = map_list_of("init", LC_INIT)("nls", LC_NLS)("ls",LC_LS)("solv", LC_SOLV)("output", LC_OUT)("event",LC_EVT)("model",LC_MOD)("other",LC_OTHER);
std::map<std::string,LogLevel> logLvlMap = map_list_of("error", LL_ERROR)("warning", LL_WARNING)("info", LL_INFO)("debug", LL_DEBUG);
std::map<std::string,OutputPointType> outputPointTypeMap = map_list_of("all", OPT_ALL)("step", OPT_STEP)("empty", OPT_EMPTY);
std::map<std::string,OutputPointType> outputPointTypeMap = map_list_of("all", OPT_ALL)("step", OPT_STEP)("none", OPT_NONE);
po::options_description desc("Allowed options");
desc.add_options()
("help", "produce help message")
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Solver/CVode/CVode.cpp
Expand Up @@ -315,7 +315,7 @@ void Cvode::initialize()
void Cvode::solve(const SOLVERCALL action)
{
bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_EMPTY);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE);

#ifdef RUNTIME_PROFILING
MEASURETIME_REGION_DEFINE(cvodeSolveFunctionHandler, "solve");
Expand Down Expand Up @@ -455,7 +455,7 @@ void Cvode::CVodeCore()
throw ModelicaSimulationError(SOLVER,"CVode::ReInit");

bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_EMPTY);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE);

while (_solverStatus & ISolver::CONTINUE && !_interrupt )
{
Expand Down
4 changes: 2 additions & 2 deletions SimulationRuntime/cpp/Solver/IDA/IDA.cpp
Expand Up @@ -283,7 +283,7 @@ void Ida::initialize()
void Ida::solve(const SOLVERCALL action)
{
bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_EMPTY);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE);

#ifdef RUNTIME_PROFILING
MEASURETIME_REGION_DEFINE(idaSolveFunctionHandler, "solve");
Expand Down Expand Up @@ -423,7 +423,7 @@ void Ida::IDACore()
throw std::runtime_error("IDA::ReInit");

bool writeEventOutput = (_settings->getGlobalSettings()->getOutputPointType() == OPT_ALL);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_EMPTY);
bool writeOutput = !(_settings->getGlobalSettings()->getOutputPointType() == OPT_NONE);

while (_solverStatus & ISolver::CONTINUE && !_interrupt )
{
Expand Down

0 comments on commit 026f2b4

Please sign in to comment.