27 void align(ofstream& ofs,
bool& is_first_parameter,
const String& indent)
30 if (is_first_parameter)
31 is_first_parameter =
false;
72 ofs <<
"// This file was generated automatically by make_auto_md_cc.cc.\n";
73 ofs <<
"// DO NOT EDIT !\n";
74 ofs <<
"// Generated: "
76 << __TIME__ <<
"\n\n";
78 ofs <<
"#include \"arts.h\"\n"
79 <<
"#include \"make_array.h\"\n"
80 <<
"#include \"auto_md.h\"\n"
81 <<
"#include \"wsv_aux.h\"\n"
82 <<
"#include \"mc_interp.h\"\n"
83 <<
"#include \"m_append.h\"\n"
84 <<
"#include \"m_delete.h\"\n"
85 <<
"#include \"m_copy.h\"\n"
86 <<
"#include \"m_conversion.h\"\n"
87 <<
"#include \"m_extract.h\"\n"
88 <<
"#include \"m_general.h\"\n"
89 <<
"#include \"m_ignore.h\"\n"
90 <<
"#include \"m_nc.h\"\n"
91 <<
"#include \"m_reduce.h\"\n"
92 <<
"#include \"m_select.h\"\n"
93 <<
"#include \"m_xml.h\"\n"
94 <<
"#include \"m_basic_types.h\"\n"
95 <<
"#include \"agenda_record.h\"\n"
96 <<
"#include \"workspace_ng.h\"\n"
97 <<
"#include \"global_data.h\"\n"
104 for (
Index i=0; i<n_md; ++i)
110 bool is_first_parameter =
true;
116 bool pass_workspace =
false;
147 for (
Index j = 0; !pass_workspace && j < mdd.
In().nelem(); j++)
151 pass_workspace =
true;
157 for (
Index j = 0; !pass_workspace && j < mdd.
GInType().nelem(); j++)
161 pass_workspace =
true;
175 ofs <<
"void " << mdd.
Name()
177 <<
"_g(Workspace&" << ws
178 <<
", const MRecord&" << mr <<
")\n"
183 ofs <<
"void " << mdd.
Name()
184 <<
"_g(Workspace&" << ws
185 <<
", const MRecord&" << mr <<
")\n"
193 #define DUMMY_ELEMS 0
194 #define DUMMY_COLS DUMMY_ELEMS
195 #define DUMMY_ROWS DUMMY_ELEMS
196 #define DUMMY_PAGES DUMMY_ELEMS
197 #define DUMMY_BOOKS DUMMY_ELEMS
198 #define DUMMY_SHELVES DUMMY_ELEMS
199 #define DUMMY_VITRINES DUMMY_ELEMS
200 #define DUMMY_LIBRARIES DUMMY_ELEMS
207 bool output_only =
true;
208 for (ArrayOfIndex::const_iterator j=mdd.
In().begin(); j != mdd.
In().end(); ++j)
215 if (output_only) voutonly.push_back(k);
220 ostringstream docstr;
221 docstr <<
" " <<
"// " << wsv_data[vo[voutonly[j]]].Name() <<
" is Output only.\n";
224 ostringstream initstr;
225 if (gname ==
"Numeric")
226 initstr <<
" = NAN;";
227 else if (gname ==
"Index")
229 else if (gname ==
"Vector")
231 else if (gname ==
"Matrix")
234 else if (gname ==
"Tensor3")
235 initstr <<
".resize("
239 else if (gname ==
"Tensor4")
240 initstr <<
".resize("
245 else if (gname ==
"Tensor5")
246 initstr <<
".resize("
252 else if (gname ==
"Tensor6")
253 initstr <<
".resize("
260 else if (gname ==
"Tensor7")
261 initstr <<
".resize("
270 if (initstr.str().length())
274 <<
" *)ws[mr.Out()[" << voutonly[j]
275 <<
"]]))" << initstr.str();
282 ofs <<
" " << mdd.
Name() <<
"(";
287 is_first_parameter =
false;
300 align(ofs,is_first_parameter,indent);
304 <<
" *)ws[mr.Out()[" << j
318 align(ofs,is_first_parameter,indent);
321 <<
" *)ws[mr.Out()[" << j+vo.
nelem()
331 align(ofs,is_first_parameter,indent);
333 ofs <<
"Workspace::wsv_data[mr.Out()["
343 align(ofs,is_first_parameter,indent);
349 <<
" *)ws[mr.In()[" << j
356 <<
" *)ws[mr.In()[" << j
366 align(ofs,is_first_parameter,indent);
368 ofs <<
"mr.SetValue()";
382 align(ofs,is_first_parameter,indent);
385 <<
" *)ws[mr.In()[" << j+vi.
nelem()
395 align(ofs,is_first_parameter,indent);
397 ofs <<
"Workspace::wsv_data[mr.In()["
408 align(ofs,is_first_parameter,indent);
414 bool pass_verbosity =
true;
417 for (
Index j = 0; pass_verbosity && j < mdd.
In().nelem(); j++)
419 if (wsv_data[mdd.
In()[j]].Name() ==
"verbosity")
421 pass_verbosity =
false;
426 for (
Index j = 0; pass_verbosity && j < mdd.
Out().nelem(); j++)
428 if (wsv_data[mdd.
Out()[j]].Name() ==
"verbosity")
430 pass_verbosity =
false;
438 align(ofs,is_first_parameter,indent);
440 <<
" *)ws[" << verbosity_wsv_id
451 bool is_first_parameter =
true;
453 ofs <<
"// The array holding the pointers to the getaway functions.\n"
454 <<
"void (*getaways[])(Workspace&, const MRecord&)\n"
456 for (
Index i=0; i<n_md; ++i)
461 align(ofs,is_first_parameter,indent);
471 ofs << mdd.
Name() <<
"_g";
490 ostringstream ain_push_os, ain_pop_os;
491 ostringstream aout_push_os, aout_pop_os;
500 ofs <<
" using global_data::AgendaMap;\n"
501 <<
" using global_data::agenda_data;\n"
503 <<
" assert(input_agenda.checked());\n"
505 <<
" const AgRecord& agr =\n"
506 <<
" agenda_data[AgendaMap.find (input_agenda.name ())->second];\n"
514 ArrayOfIndex::const_iterator it = agi.begin ();
515 while (it != agi.end () && *it != ago[j]) it++;
516 if (it == agi.end ())
518 aout_push_os <<
" ws.push_uninitialized (aout[" << j <<
"], "
519 <<
"(void *)&" << wsv_data[ago[j]].Name () <<
");\n";
523 aout_push_os <<
" ws.push (aout[" << j <<
"], "
524 <<
"(void *)&" << wsv_data[ago[j]].Name () <<
");\n";
526 aout_pop_os <<
" ws.pop (aout[" << j <<
"]);\n";
534 ArrayOfIndex::const_iterator it = ago.begin ();
535 while (it != ago.end () && *it != agi[j]) it++;
536 if (it == ago.end ())
538 ain_push_os <<
" ws.push (ain[" << j <<
"], "
539 <<
"(void *)&" << wsv_data[agi[j]].Name () <<
");\n";
540 ain_pop_os <<
" ws.pop (ain[" << j <<
"]);\n";
545 if (aout_push_os.str().length())
547 ofs <<
" const ArrayOfIndex& aout = agr.Out();\n";
548 ofs << aout_push_os.str () <<
"\n";
550 if (ain_push_os.str().length())
552 ofs <<
" const ArrayOfIndex& ain = agr.In();\n";
553 ofs << ain_push_os.str () <<
"\n";
556 ofs <<
" const ArrayOfIndex& outputs_to_push = input_agenda.get_output2push();\n"
557 <<
" const ArrayOfIndex& outputs_to_dup = input_agenda.get_output2dup();\n"
559 <<
" for (ArrayOfIndex::const_iterator it = outputs_to_push.begin ();\n"
560 <<
" it != outputs_to_push.end (); it++)\n"
566 <<
" if (ws.is_initialized(*it))\n"
567 <<
" ws.duplicate (*it);\n"
569 <<
" ws.push_uninitialized (*it, NULL);\n"
572 <<
" for (ArrayOfIndex::const_iterator it = outputs_to_dup.begin ();\n"
573 <<
" it != outputs_to_dup.end (); it++)\n"
574 <<
" { ws.duplicate (*it); }\n"
577 ofs <<
" String agenda_error_msg;\n"
578 <<
" bool agenda_failed = false;\n\n"
580 <<
" input_agenda.execute (ws);\n"
581 <<
" } catch (runtime_error e) {\n"
582 <<
" ostringstream os;\n"
583 <<
" os << \"Run-time error in agenda: \"\n"
584 <<
" << input_agenda.name() << \'\\n\' << e.what();\n"
585 <<
" agenda_failed = true;\n"
586 <<
" agenda_error_msg = os.str();\n"
589 ofs <<
" for (ArrayOfIndex::const_iterator it = outputs_to_push.begin ();\n"
590 <<
" it != outputs_to_push.end (); it++)\n"
591 <<
" { ws.pop_free (*it); }\n"
593 <<
" for (ArrayOfIndex::const_iterator it = outputs_to_dup.begin ();\n"
594 <<
" it != outputs_to_dup.end (); it++)\n"
595 <<
" { ws.pop_free (*it); }\n\n";
597 if (aout_pop_os.str().length())
599 ofs << aout_pop_os.str () <<
"\n";
601 if (ain_pop_os.str().length())
603 ofs << ain_pop_os.str () <<
"\n";
606 ofs <<
" if (agenda_failed) throw runtime_error (agenda_error_msg);\n\n";
620 <<
"/* Workspace method: Doxygen documentation will be auto-generated */\n"
621 <<
"void " << *it <<
"Create(" << *it <<
"& var, const Verbosity&)\n"
628 else if (*it ==
"Numeric")
631 ofs <<
"var = " << *it <<
"();";
637 catch (runtime_error x)
639 cout <<
"Something went wrong. Message text:\n";
640 cout << x.what() <<
'\n';