41 #include <util/visitors/partition_interval.hpp>
51 : _fname(model.name()), _model(model), _modelInstance(modelInstance), _writer(std::make_shared<
FileWriter>()), _flags(flags)
68 stringstream includes;
71 fname.append(
".makefile");
73 _writer->print(
"#Compiler and Linker");
76 _writer->print(
"#The Target Binary Program ");
79 _writer->print(
"#Flags, Libraries and Includes");
83 for (
string l = tmp.
begin(it); !tmp.
end(it); l = tmp.
next(it)) {
84 includes <<
" -L " << l;
88 buffer <<
"LIBS :=" << (
_flags.
debug() ?
" -lqssd -ltimestepd" :
" -lqss -ltimestep");
92 for (
string i = tmp.
begin(it); !tmp.
end(it); i = tmp.
next(it)) {
97 for (
auto obj : objects) {
98 unsigned long f = obj.rfind(
"/");
99 obj.erase(obj.begin() + f, obj.end());
104 include[pinclude] = pinclude;
107 include.
insert(pinclude, pinclude);
109 for (
string i = include.
begin(it); !include.
end(it); i = include.
next(it)) {
110 buffer <<
" -I" << i;
114 _writer->print(
"CFLAGS := -Wall -g -msse2 -mfpmath=sse $(LDFLAGS) $(LIBS)");
116 _writer->print(
"CFLAGS := -Wall -msse2 -mfpmath=sse -O2 $(LDFLAGS) $(LIBS)");
119 for (
string i = tmp.
begin(it); !tmp.
end(it); i = tmp.
next(it)) {
120 includes <<
" -l" << i;
122 _writer->print(
"RMS := rm -rf");
124 _writer->print(
"#Source Files");
125 buffer <<
"TARGET_SRC := " <<
_fname <<
".c";
127 buffer <<
" " <<
_fname <<
"_functions.c";
133 for (
const auto& obj : objects) {
134 buffer << obj <<
" ";
141 _writer->print(
"OBJ = $(SRC:.c=.o)");
143 _writer->print(
_writer->indent(1) +
"$(CC) $(INC) -c $< -o $@ $(CFLAGS)");
146 _writer->print(
"default: $(TARGET)");
148 buffer <<
"$(TARGET):";
153 buffer <<
_writer->indent(1) <<
"$(CC) $(INC)";
157 buffer <<
" $(TARGET_SRC) $(CFLAGS) -o $@ -lm -lgsl -lconfig -lgfortran";
159 buffer <<
" -lpthread -lmetis -lscotch -lscotcherr -lpatoh -lrt -lsundials_cvode -lsundials_ida -lsundials_nvecserial -llapack -latlas "
162 buffer <<
" -lgslcblas" << includes.str();
164 buffer <<
" -DQSS_PARALLEL";
168 _writer->print(
".PHONY: clean");
171 _writer->print(
_writer->indent(1) +
"$(RMS) $(TARGET) *.dat *.log");
184 buffer <<
"make -f " +
_fname +
".makefile";
194 chmod(fname.c_str(), S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
268 fname.append(
".ini");
271 buffer <<
"minstep=" << scientific << annotation.
minStep() <<
";";
273 buffer <<
"zchyst=" << annotation.
ZCHyst() <<
";";
275 buffer <<
"derdelta=" << annotation.
derDelta() <<
";";
277 buffer <<
"symdiff=" << annotation.
symDiff() <<
";";
280 buffer <<
"lps=" << annotation.
lps() <<
";";
284 buffer <<
"dt=" << annotation.
DT() <<
";";
286 buffer <<
"dtSynch=\"" << annotation.
dtSynchString() <<
"\";";
291 buffer <<
"nodesize=" << annotation.
nodeSize() <<
";";
293 buffer <<
"jacobian=" << (annotation.
jacobian()) <<
";";
295 buffer <<
"it=" << annotation.
initialTime() <<
";";
297 buffer <<
"ft=" << annotation.
finalTime() <<
";";
300 list<double> dq = annotation.
dqmin();
302 unsigned long count = 0;
303 unsigned long size = dq.size();
304 for (
const auto& it : dq) {
306 if (++count < size) {
312 dq = annotation.
dqrel();
316 for (
const auto& it : dq) {
318 if (++count < size) {
336 buffer <<
"BDFMaxStep=" << annotation.
BDFMaxStep() <<
";";
338 addAnnotation(annotation,
"CVODEMaxOrder", IntegerAnnotations::CVODEMaxOrder);
339 addAnnotation(annotation,
"XOutput", IntegerAnnotations::XOutput);
347 buffer << mmo_name <<
"=" << annotation.
getAnnotation(name) <<
";";
358 buffer << tag <<
"=(";
359 unsigned long count = 0;
360 unsigned long size = ann.size();
361 for (
const auto& it : ann) {
363 if (++count < size) {
374 AST_ExpressionListIterator bdf_exp_it;
376 foreach (bdf_exp_it, BDF_exps) {
377 PartitionInterval partition_interval;
379 variables.splice(variables.end(), ret);
381 string file_name =
_fname +
"_BDF.part";
382 ofstream partition(file_name.c_str(), ios::out);
383 unsigned long partition_size = variables.size();
384 partition << partition_size << endl;
385 for (
const auto& var_it : variables) {
386 partition << var_it << endl;