26 void align(ofstream& ofs,
bool& is_first_parameter,
const String& indent)
29 if (is_first_parameter)
30 is_first_parameter =
false;
71 ofs <<
"// This file was generated automatically by make_auto_md_cc.cc.\n";
72 ofs <<
"// DO NOT EDIT !\n";
73 ofs <<
"// Generated: "
75 << __TIME__ <<
"\n\n";
77 ofs <<
"#include \"arts.h\"\n"
78 <<
"#include \"make_array.h\"\n"
79 <<
"#include \"auto_md.h\"\n"
80 <<
"#include \"wsv_aux.h\"\n"
81 <<
"#include \"mc_interp.h\"\n"
82 <<
"#include \"m_append.h\"\n"
83 <<
"#include \"m_delete.h\"\n"
84 <<
"#include \"m_copy.h\"\n"
85 <<
"#include \"m_conversion.h\"\n"
86 <<
"#include \"m_extract.h\"\n"
87 <<
"#include \"m_general.h\"\n"
88 <<
"#include \"m_ignore.h\"\n"
89 <<
"#include \"m_nc.h\"\n"
90 <<
"#include \"m_select.h\"\n"
91 <<
"#include \"m_xml.h\"\n"
92 <<
"#include \"m_basic_types.h\"\n"
93 <<
"#include \"agenda_record.h\"\n"
94 <<
"#include \"workspace_ng.h\"\n"
101 for (
Index i=0; i<n_md; ++i)
107 bool is_first_parameter =
true;
113 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
199 ostringstream docstr;
200 docstr <<
" " <<
"// " << wsv_data[voutonly[j]].Name() <<
" is Output only.\n";
203 ostringstream initstr;
204 if (gname ==
"Numeric")
205 initstr <<
" = NAN;";
206 else if (gname ==
"Index")
208 else if (gname ==
"Vector")
210 else if (gname ==
"Matrix")
213 else if (gname ==
"Tensor3")
219 if (initstr.str().length())
223 <<
" *)ws[" << voutonly[j]
224 <<
"]))" << initstr.str();
231 ofs <<
" " << mdd.
Name() <<
"(";
236 is_first_parameter =
false;
249 align(ofs,is_first_parameter,indent);
253 <<
" *)ws[mr.Out()[" << j
267 align(ofs,is_first_parameter,indent);
270 <<
" *)ws[mr.Out()[" << j+vo.
nelem()
280 align(ofs,is_first_parameter,indent);
282 ofs <<
"Workspace::wsv_data[mr.Out()["
292 align(ofs,is_first_parameter,indent);
298 <<
" *)ws[mr.In()[" << j
305 <<
" *)ws[mr.In()[" << j
315 align(ofs,is_first_parameter,indent);
317 ofs <<
"mr.SetValue()";
331 align(ofs,is_first_parameter,indent);
334 <<
" *)ws[mr.In()[" << j+vi.
nelem()
344 align(ofs,is_first_parameter,indent);
346 ofs <<
"Workspace::wsv_data[mr.In()["
357 align(ofs,is_first_parameter,indent);
363 bool pass_verbosity =
true;
366 for (
Index j = 0; pass_verbosity && j < mdd.
In().nelem(); j++)
368 if (wsv_data[mdd.
In()[j]].Name() ==
"verbosity")
370 pass_verbosity =
false;
375 for (
Index j = 0; pass_verbosity && j < mdd.
Out().nelem(); j++)
377 if (wsv_data[mdd.
Out()[j]].Name() ==
"verbosity")
379 pass_verbosity =
false;
387 align(ofs,is_first_parameter,indent);
389 <<
" *)ws[" << verbosity_wsv_id
400 bool is_first_parameter =
true;
402 ofs <<
"// The array holding the pointers to the getaway functions.\n"
403 <<
"void (*getaways[])(Workspace&, const MRecord&)\n"
405 for (
Index i=0; i<n_md; ++i)
410 align(ofs,is_first_parameter,indent);
420 ofs << mdd.
Name() <<
"_g";
439 ostringstream ain_push_os, ain_pop_os;
440 ostringstream aout_push_os, aout_pop_os;
449 ofs <<
" extern map<String, Index> AgendaMap;\n"
450 <<
" extern const Array<AgRecord> agenda_data;\n"
452 <<
" const AgRecord& agr =\n"
453 <<
" agenda_data[AgendaMap.find (input_agenda.name ())->second];\n"
461 ArrayOfIndex::const_iterator it = agi.begin ();
462 while (it != agi.end () && *it != ago[j]) it++;
463 if (it == agi.end ())
465 aout_push_os <<
" ws.push_uninitialized (aout[" << j <<
"], "
466 <<
"(void *)&" << wsv_data[ago[j]].Name () <<
");\n";
470 aout_push_os <<
" ws.push (aout[" << j <<
"], "
471 <<
"(void *)&" << wsv_data[ago[j]].Name () <<
");\n";
473 aout_pop_os <<
" ws.pop (aout[" << j <<
"]);\n";
481 ArrayOfIndex::const_iterator it = ago.begin ();
482 while (it != ago.end () && *it != agi[j]) it++;
483 if (it == ago.end ())
485 ain_push_os <<
" ws.push (ain[" << j <<
"], "
486 <<
"(void *)&" << wsv_data[agi[j]].Name () <<
");\n";
487 ain_pop_os <<
" ws.pop (ain[" << j <<
"]);\n";
492 if (aout_push_os.str().length())
494 ofs <<
" const ArrayOfIndex& aout = agr.Out();\n";
495 ofs << aout_push_os.str () <<
"\n";
497 if (ain_push_os.str().length())
499 ofs <<
" const ArrayOfIndex& ain = agr.In();\n";
500 ofs << ain_push_os.str () <<
"\n";
503 ofs <<
" const ArrayOfIndex& outputs_to_push = input_agenda.get_output2push();\n"
504 <<
" const ArrayOfIndex& outputs_to_dup = input_agenda.get_output2dup();\n"
506 <<
" for (ArrayOfIndex::const_iterator it = outputs_to_push.begin ();\n"
507 <<
" it != outputs_to_push.end (); it++)\n"
508 <<
" { ws.push (*it, NULL); }\n"
510 <<
" for (ArrayOfIndex::const_iterator it = outputs_to_dup.begin ();\n"
511 <<
" it != outputs_to_dup.end (); it++)\n"
512 <<
" { ws.duplicate (*it); }\n"
515 ofs <<
" String agenda_error_msg;\n"
516 <<
" bool agenda_failed = false;\n\n"
518 <<
" input_agenda.execute (ws);\n"
519 <<
" } catch (runtime_error e) {\n"
520 <<
" ostringstream os;\n"
521 <<
" os << \"Run-time error in agenda: \"\n"
522 <<
" << input_agenda.name() << \'\\n\' << e.what();\n"
523 <<
" agenda_failed = true;\n"
524 <<
" agenda_error_msg = os.str();\n"
527 ofs <<
" for (ArrayOfIndex::const_iterator it = outputs_to_push.begin ();\n"
528 <<
" it != outputs_to_push.end (); it++)\n"
529 <<
" { ws.pop_free (*it); }\n"
531 <<
" for (ArrayOfIndex::const_iterator it = outputs_to_dup.begin ();\n"
532 <<
" it != outputs_to_dup.end (); it++)\n"
533 <<
" { ws.pop_free (*it); }\n\n";
535 if (aout_pop_os.str().length())
537 ofs << aout_pop_os.str () <<
"\n";
539 if (ain_pop_os.str().length())
541 ofs << ain_pop_os.str () <<
"\n";
544 ofs <<
" if (agenda_failed) throw runtime_error (agenda_error_msg);\n\n";
558 <<
"/* Workspace method: Doxygen documentation will be auto-generated */\n"
559 <<
"void " << *it <<
"Create(" << *it <<
"& var, const Verbosity&)\n"
566 else if (*it ==
"Numeric")
569 ofs <<
"var = " << *it <<
"();";
575 catch (runtime_error x)
577 cout <<
"Something went wrong. Message text:\n";
578 cout << x.what() <<
'\n';