18 std::vector<std::string>
desc;
20 std::vector<std::string>
name;
21 std::vector<std::string>
defs;
26 std::vector<std::string>
desc;
28 std::vector<std::string>
name;
61 std::vector<std::string>
ins;
62 std::vector<std::string>
outs;
65std::map<std::string, Group>
groups() {
66 std::map<std::string, std::size_t> group;
68 std::map<std::string, std::size_t> name;
70 std::map<std::string, std::string> desc;
72 std::map<std::string, std::size_t> pos;
75 std::map<std::string, Group> out;
76 for (
auto& x : name) {
77 for (
auto& y : group) {
78 if (y.second == x.second) {
79 out[x.first] = {y.first, desc[x.first], pos[x.first]};
88 const std::vector<std::string>& vargroups,
89 const std::vector<std::string>& vardefaults) {
90 std::vector<std::string> defaults(vargroups.size());
91 std::vector<bool> hasdefaults(vargroups.size());
92 for (
size_t i = 0; i < vargroups.size(); i++) {
93 if (vardefaults[i] ==
NODEF)
94 hasdefaults[i] =
false;
96 hasdefaults[i] =
true;
98 if (vargroups[i] ==
"String") {
99 defaults[i] = std::string(
"\"") + vardefaults[i] + std::string(
"\"");
100 }
else if (vargroups[i] ==
"Numeric") {
101 if (
"NaN" == vardefaults[i] or
"nan" == vardefaults[i]) {
102 defaults[i] =
"std::numeric_limits<Numeric>::quiet_NaN()";
103 }
else if (
"Inf" == vardefaults[i] or
"inf" == vardefaults[i]) {
104 defaults[i] =
"std::numeric_limits<Numeric>::infinity()";
105 }
else if (
"-Inf" == vardefaults[i] or
"-inf" == vardefaults[i]) {
106 defaults[i] =
"-std::numeric_limits<Numeric>::infinity()";
108 defaults[i] = vardefaults[i];
110 }
else if (vardefaults[i] ==
"[]") {
113 defaults[i] = vardefaults[i];
116 if (defaults[i] ==
"") defaults[i] =
"{}";
118 for (
auto& x : defaults[i]) {
126 return {defaults, hasdefaults};
130 std::map<std::string, std::size_t> vargroup;
132 std::map<std::string, std::size_t> varpos;
134 std::map<std::string, std::size_t> methodpos;
137 std::vector<std::string> metname;
139 std::vector<std::string> actual_groups;
141 actual_groups.push_back(x.ActualGroups());
142 std::vector<std::vector<std::size_t>> gin_group;
144 gin_group.emplace_back(x.GInType().cbegin(), x.GInType().cend());
145 std::vector<std::vector<std::string>> gin_names;
147 gin_names.emplace_back(x.GIn().cbegin(), x.GIn().cend());
148 std::vector<std::vector<std::string>> gin_defaults;
150 gin_defaults.emplace_back(x.GInDefault().cbegin(), x.GInDefault().cend());
151 std::vector<std::vector<std::string>> gin_desc;
153 gin_desc.emplace_back(x.GInDescription().cbegin(), x.GInDescription().cend());
154 std::vector<std::vector<std::size_t>> gout_group;
156 gout_group.emplace_back(x.GOutType().cbegin(), x.GOutType().cend());
157 std::vector<std::vector<std::string>> gout_names;
159 gout_names.emplace_back(x.GOut().cbegin(), x.GOut().cend());
160 std::vector<std::vector<std::string>> gout_desc;
162 gout_desc.emplace_back(x.GOutDescription().cbegin(), x.GOutDescription().cend());
163 std::vector<std::vector<std::size_t>> in_wspace;
165 in_wspace.emplace_back(x.In().cbegin(), x.In().cend());
166 std::vector<std::vector<std::size_t>> out_wspace;
168 out_wspace.emplace_back(x.Out().cbegin(), x.Out().cend());
169 std::vector<std::string> desc;
171 std::vector<std::vector<std::string>> authors;
173 authors.emplace_back(x.Authors().cbegin(), x.Authors().cend());
175 std::vector<bool> set_method;
177 std::vector<bool> agenda_method;
179 agenda_method.push_back(x.AgendaMethod());
180 std::vector<bool> supergeneric;
182 std::vector<bool> uses_templates;
184 uses_templates.push_back(x.UsesTemplates());
185 std::vector<bool> pass_workspace;
187 pass_workspace.push_back(x.PassWorkspace());
188 std::vector<bool> pass_wsv_names;
190 pass_wsv_names.push_back(x.PassWsvNames());
192 std::vector<std::vector<std::size_t>> inoutvarpos;
194 inoutvarpos.emplace_back(x.InOut().cbegin(), x.InOut().cend());
195 std::vector<std::vector<std::size_t>> invarpos;
197 invarpos.emplace_back(x.InOnly().cbegin(), x.InOnly().cend());
198 std::vector<std::vector<std::size_t>> outvarpos;
200 outvarpos.emplace_back(x.Out().cbegin(), x.Out().cend());
202 std::vector<Method> retval;
203 for (std::size_t i = 0; i < desc.size(); i++) {
207 m.
pos = methodpos[metname[i] +
String(
"_sg_") + actual_groups[i]];
209 m.
pos = methodpos[metname[i]];
214 gin.
desc = gin_desc[i];
215 for (
auto g : gin_group[i]) {
217 for (
auto& y : vargroup) {
219 gin.
group.push_back(y.first);
225 std::cerr <<
"Cannot find group\n";
229 gin.
name = gin_names[i];
231 gin.
defs = fixgin.first;
236 gout.
desc = gout_desc[i];
237 for (
auto g : gout_group[i]) {
239 for (
auto& y : vargroup) {
241 gout.
group.push_back(y.first);
247 std::cerr <<
"Cannot find group\n";
251 gout.
name = gout_names[i];
255 for (
auto v : in_wspace[i]) {
257 for (
auto& y : varpos) {
265 std::cerr <<
"Cannot find variable\n";
273 for (
auto v : out_wspace[i]) {
275 for (
auto& y : varpos) {
277 out.
varname.push_back(y.first);
283 std::cerr <<
"Cannot find variable\n";
287 out.
varpos = outvarpos[i];
306 std::map<std::string, AgendaData> out;
309 out[x.Name()].desc = x.Description();
311 for (std::size_t i : x.In()) {
314 if (y.second.artspos == i) {
315 out[x.Name()].ins.push_back(y.first);
321 std::cerr <<
"Cannot find the variable\n";
326 for (std::size_t i : x.Out()) {
329 if (y.second.artspos == i) {
330 out[x.Name()].outs.push_back(y.first);
336 std::cerr <<
"Cannot find the variable\n";
348 std::map<std::string, std::size_t>
group;
359 std::cout <<
"#include <auto_md.h>" <<
'\n'
360 <<
"#include <arts.h>" <<
'\n'
361 <<
"#include <global_data.h>" <<
'\n'
362 <<
"#include <m_basic_types.h>" <<
'\n'
363 <<
"#include <m_general.h>" <<
'\n'
364 <<
"#include <m_append.h>" <<
'\n'
365 <<
"#include <m_conversion.h>" <<
'\n'
366 <<
"#include <m_copy.h>" <<
'\n'
367 <<
"#include <m_gridded_fields.h>" <<
'\n'
368 <<
"#include <m_xml.h>" <<
'\n'
369 <<
"#include <m_select.h>" <<
'\n'
370 <<
"#include <m_reduce.h>" <<
'\n'
371 <<
"#include <m_nc.h>" <<
'\n'
372 <<
"#include <m_delete.h>" <<
'\n'
373 <<
"#include <m_extract.h>" <<
'\n'
374 <<
"#include <m_ignore.h>" <<
'\n'
375 <<
"#include <isotopologues.h>" <<
'\n'
379 std::cout <<
"extern String out_basename;\n\n";
383 std::cout <<
"/*! An ARTS Workspace, the main class of ARTS */\n";
384 std::cout <<
"using Workspace=Workspace; \n\n";
385 std::cout <<
"/*! The ARTS constants namespace */\n";
386 std::cout <<
"namespace Constant { using namespace ::Constant; }\n\n";
387 std::cout <<
"/*! The ARTS conversions namespace */\n";
388 std::cout <<
"namespace Conversion { using namespace ::Conversion; }\n\n";
389 std::cout <<
"/*! The ARTS Group namespace */\n";
390 std::cout <<
"namespace Group {\n";
391 for (
auto& x : artsname.
group) {
392 if (x.first ==
"Any")
continue;
393 std::cout <<
"/*! ARTS " << x.first <<
" type */\n";
394 std::cout <<
"using " << x.first <<
'=' << x.first <<
';' <<
'\n' <<
'\n';
397 std::cout <<
"/*! The ARTS Internal Groups namespace */\n";
398 std::cout <<
"namespace Internal {\n";
399 std::cout <<
"/*! A Tokenized Value. Used purely in internal code */\n";
400 std::cout <<
"using TokVal=TokVal;\n" <<
'\n';
401 std::cout <<
"/*! A Method Record. Used to pass methods to agendas */\n";
402 std::cout <<
"using MRecord=MRecord;\n" <<
'\n';
403 std::cout <<
"} // namespace Internal\n";
404 std::cout <<
"} // namespace Group \n\n";
408 std::cout <<
"namespace Var {\n";
409 for (
auto& x : artsname.
group) {
410 if (x.first ==
"Any")
continue;
411 std::cout <<
"/*! Workspace Variable class. Used as default\n"
412 " input to many Method and AgendaMethod.\n"
413 " Note that it is not recommended to manually\n"
414 " create this class as many methods makes distinct\n"
415 " assumptions about the states that this class are\n"
416 " allowed to be in */\n";
417 std::cout <<
"class " << x.first <<
' ' <<
'{' <<
'\n';
418 std::cout <<
" std::size_t p;\n";
419 std::cout <<
" Group::" << x.first <<
"* v;\n";
420 std::cout <<
"public:\n";
421 std::cout <<
" /*! Default construct. DO NOT USE MANUALLY. Leaves "
422 "islast() true and isnull() true */\n";
423 std::cout <<
" " << x.first
424 <<
"() noexcept : p(std::numeric_limits<std::size_t>::max()), "
426 std::cout <<
" /*! Construct from existing Workspace. DO NOT USE "
427 "MANUALLY. Leaves islast() false and isnull() false */\n";
428 std::cout <<
" " << x.first
429 <<
"(std::size_t i, void * x) noexcept : p(i), "
430 "v(static_cast<Group::" << x.first <<
" *>(x)) {}\n\n";
431 std::cout <<
" /*! Construct from Group::" << x.first <<
". Leaves islast() true and "
432 "isnull() false */\n";
433 std::cout <<
" " << x.first
434 <<
"(const Group::" << x.first <<
"& val) noexcept : "
435 "p(std::numeric_limits<std::size_t>::max()), v(new Group::" << x.first <<
"(val)) "
437 std::cout <<
" /*! Delete data only when islast() is true and isnull() is "
439 std::cout <<
" ~" << x.first
440 <<
"() noexcept {if (islast() and not isnull()) delete v;}\n\n";
442 <<
" /*! Get value ref as Group::" << x.first <<
". Works when isnull() is false */\n";
443 std::cout <<
" Group::" << x.first <<
"& value() noexcept {return *v;}\n\n";
445 <<
" /*! Get value const-ref as Group::" << x.first <<
". Works when isnull() is false */\n";
446 std::cout <<
" const Group::" << x.first <<
"& value() const noexcept {return *v;}\n\n";
447 std::cout <<
" /*! Set value from Group::" << x.first <<
". Works when isnull() is "
449 std::cout <<
" " << x.first
450 <<
"& operator=(const Group::" << x.first <<
"& t) noexcept {value() = t; return "
453 <<
" /*! Return the position of the variable in the Workspace */\n";
454 std::cout <<
" std::size_t pos() const noexcept {return p;}\n\n";
455 std::cout <<
" /*! Return true if there is no data */\n";
456 std::cout <<
" bool isnull() const noexcept {return v == nullptr;}\n\n";
457 std::cout <<
" /*! Return true if data is not in the Workspace */\n";
458 std::cout <<
" bool islast() const noexcept {return p == "
459 "std::numeric_limits<std::size_t>::max();}\n\n";
460 std::cout <<
" /*! Name of variable. Must be in the workspace */\n";
461 std::cout <<
" const Group::String& name() const noexcept {return "
462 "Workspace::wsv_data[p].Name();}\n\n";
466 if (x.first not_eq
"Ppath" and x.first not_eq
"TessemNN" and
467 x.first not_eq
"Timer" and x.first not_eq
"ArrayOfPpath") {
468 std::cout <<
" /*! Output to stream of internal variable */\n";
469 std::cout <<
" friend std::ostream& operator<<(std::ostream& os, const "
471 <<
"& var) {if (var.isnull()) return os << \"NULLDATA\"; else "
472 "return os << var.value();}\n";
475 std::cout <<
'}' <<
';' <<
'\n' <<
'\n';
478 std::cout <<
"/*! " << x.second.varname_desc <<
'\n';
479 std::cout <<
"@param[in,out] Workspace ws - An ARTS workspace\n";
480 std::cout <<
"@return A class with a pointer to this variable and its "
481 "position in the workspace\n*/\n";
482 std::cout <<
"[[nodiscard]] inline ";
483 std::cout << x.second.varname_group <<
' ' << x.first
484 <<
"(Workspace& ws) "
487 << x.second.artspos <<
", ws[" << x.second.artspos
491 for (
auto& x : artsname.
group) {
492 if (x.first ==
"Any")
continue;
494 std::cout <<
"/*! Creates in, and returns from, Workspace a/an " << x.first
497 std::cout <<
"@param[in,out] Workspace ws - An ARTS workspace\n";
498 std::cout <<
"@param[in] " << x.first
499 <<
" inval - The default value the variable will have in "
501 std::cout <<
"@param[in] String name - The name the variable will have in "
503 std::cout <<
"@param[in] String desc - The description the variable will "
504 "have in the workspace (default: \"nodescription\")\n";
505 std::cout <<
"@return A class with a pointer to this variable and its new "
506 "position in the workspace\n";
508 std::cout <<
"[[nodiscard]] inline\n";
510 << x.first <<
' ' << x.first
511 <<
"Create(\n Workspace& ws,\n const Group::"
513 <<
"& inval,\n const Group::String& name,\n "
516 "desc=\"nodescription\") {\n";
517 std::cout <<
" const std::size_t ind = "
518 "std::size_t(ws.add_wsv_inplace({name.c_str(), desc.c_str(), "
519 << x.second <<
"}));\n";
520 std::cout <<
" " << x.first <<
' ' <<
"val{ind, ws[ind]};\n";
521 std::cout <<
" return val = inval;\n"
524 std::cout <<
"} // namespace Var \n\n";
529 for (std::size_t i=0; i<n; i++)
537 if (x.agenda_method)
continue;
540 if (std::any_of(artsname.
group.cbegin(), artsname.
group.cend(),
541 [metname = x.name](
auto& y) {
542 return (y.first + String(
"Create")) == metname;
547 std::cout <<
"/*! " << x.desc <<
'\n';
548 for (
const auto&
a : x.authors) std::cout <<
"@author " <<
a <<
'\n';
550 "@param[in,out] Workspace ws - An ARTS workspace\n";
551 for (std::size_t i = 0; i < x.gout.name.size(); i++)
552 std::cout <<
"@param[out] " << x.gout.name[i] <<
" - " << x.gout.desc[i]
554 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
555 std::cout <<
"@param[in] " << x.gin.name[i] <<
" - " << x.gin.desc[i];
556 if (x.gin.hasdefs[i]) std::cout <<
" (default: " << x.gin.defs[i] <<
")";
559 std::cout <<
"\nUse the ARTS documentation to read more on how the "
560 "workspace is manipulated\n";
561 std::cout <<
"This interface function has been automatically generated\n";
562 std::cout <<
"*/" <<
'\n';
565 std::cout <<
"inline void " << x.name <<
"(Workspace& ws";
568 for (std::size_t i = 0; i < x.gout.group.size(); i++) {
569 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13) <<
"Var::" << x.gout.group[i] <<
' '
574 for (std::size_t i = 0; i < x.gin.group.size(); i++) {
575 if (not x.gin.hasdefs[i]) {
576 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13 - 6)
577 <<
"const Var::" << x.gin.group[i] <<
' ' << x.gin.name[i];
582 for (std::size_t i = 0; i < x.gin.group.size(); i++) {
583 if (x.gin.hasdefs[i]) {
584 if (x.gin.defs[i] ==
"{}") {
585 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13 - 6)
586 <<
"const Var::" << x.gin.group[i] <<
' ' << x.gin.name[i]
587 <<
'=' <<
"Group::" << x.gin.group[i] << x.gin.defs[i];
589 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13 - 6)
590 <<
"const Var::" << x.gin.group[i] <<
' ' << x.gin.name[i]
591 <<
'=' <<
"Group::" << x.gin.group[i] <<
'{'
592 << x.gin.defs[i] <<
'}';
598 std::cout <<
')' <<
' ' <<
'{' <<
'\n';
601 if (x.gout.group.size()) std::cout <<
' ';
602 for (std::size_t i = 0; i < x.gout.group.size(); i++) {
603 std::cout <<
" if (" << x.gout.name[i]
604 <<
".islast()) {\n throw std::runtime_error(\""
605 << x.gout.name[i] <<
" needs to be a defined "
606 << x.gout.group[i] <<
" since it is output of " << x.name
609 if (x.gout.group.size()) std::cout <<
'\n' <<
'\n';
612 std::cout <<
' ' <<
' ' << x.name <<
'(';
615 bool has_any =
false;
616 if (x.pass_workspace or x.agenda_method or
618 x.gin.group.cbegin(), x.gin.group.cend(),
619 [](
auto& g) { return g ==
"Agenda" or g ==
"ArrayOfAgenda"; }) or
620 std::any_of(x.in.varname.cbegin(), x.in.varname.cend(), [&](
auto& g) {
621 return artsname.varname_group.at(g).varname_group ==
"Agenda" or
622 artsname.varname_group.at(g).varname_group ==
"ArrayOfAgenda";
629 for (std::size_t i = 0; i < x.out.varname.size(); i++) {
630 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
632 std::cout <<
"Var::" << x.out.varname[i] <<
"(ws).value()";
636 for (std::size_t i = 0; i < x.gout.name.size(); i++) {
637 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
639 std::cout << x.gout.name[i];
640 std::cout <<
".value()";
644 if (x.pass_wsv_names) {
645 for (std::size_t i = 0; i < x.gout.name.size(); i++) {
646 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
648 std::cout << x.gout.name[i] <<
".name()";
653 for (std::size_t i = 0; i < x.in.varname.size(); i++) {
655 x.out.varname.cbegin(), x.out.varname.cend(),
656 [in = x.in.varname[i]](
const auto& out) { return in == out; }))
658 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
660 std::cout <<
"Var::" << x.in.varname[i] <<
"(ws).value()";
664 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
665 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
667 std::cout << x.gin.name[i];
668 std::cout <<
".value()";
672 if (x.pass_wsv_names) {
673 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
674 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
676 std::cout << x.gin.name[i] <<
".islast() ? Group::String{\""
677 << x.gin.name[i] <<
"\"} : " << x.gin.name[i] <<
".name()";
682 const bool has_verbosity =
683 std::any_of(x.in.varname.cbegin(), x.in.varname.cend(),
684 [](
auto& name) { return name ==
"verbosity"; });
687 if (not has_verbosity) {
688 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
690 std::cout <<
"Var::verbosity(ws).value()";
694 std::cout <<
')' <<
';' <<
'\n' <<
'}' <<
'\n' <<
'\n' <<
'\n';
701 if (x.agenda_method)
continue;
704 if (std::any_of(artsname.
group.cbegin(), artsname.
group.cend(),
705 [metname = x.name](
auto& y) {
706 return (y.first + String(
"Create")) == metname;
711 if (not x.out.varname.size() and not x.gout.name.size() and
712 not x.in.varname.size() and not x.gin.name.size())
716 std::cout <<
"/*! " << x.desc <<
'\n';
717 for (
const auto&
a : x.authors) std::cout <<
"@author " <<
a <<
'\n';
719 "@param[in,out] Workspace ws - An ARTS workspace\n";
720 for (std::size_t i = 0; i < x.out.varname.size(); i++) {
722 x.in.varname.cbegin(), x.in.varname.cend(),
723 [out = x.out.varname[i]](
const auto& in) { return in == out; }))
724 std::cout <<
"@param[in,out] ";
726 std::cout <<
"@param[out] ";
727 std::cout << x.out.varname[i] <<
" - as *Var::" << x.out.varname[i]
730 for (std::size_t i = 0; i < x.gout.name.size(); i++)
731 std::cout <<
"@param[out] " << x.gout.name[i] <<
" - " << x.gout.desc[i]
733 for (std::size_t i = 0; i < x.in.varname.size(); i++) {
735 x.out.varname.cbegin(), x.out.varname.cend(),
736 [in = x.in.varname[i]](
const auto& out) { return in == out; }))
738 std::cout <<
"@param[in] " << x.in.varname[i]
739 <<
" - as *Var::" << x.in.varname[i] <<
"(ws)*\n";
741 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
742 std::cout <<
"@param[in] " << x.gin.name[i] <<
" - " << x.gin.desc[i];
743 if (x.gin.hasdefs[i]) std::cout <<
" (default: " << x.gin.defs[i] <<
")";
746 std::cout <<
"\nUse the ARTS documentation to read more on how the "
747 "workspace is manipulated\n";
748 std::cout <<
"This interface function has been automatically generated\n";
749 std::cout <<
"*/" <<
'\n';
752 std::cout <<
"inline void " << x.name
753 <<
"(Workspace& ws [[maybe_unused]]";
756 for (std::size_t i = 0; i < x.out.varname.size(); i++)
757 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13) <<
"Group::"
759 <<
'&' <<
' ' << x.out.varname[i];
762 for (std::size_t i = 0; i < x.gout.group.size(); i++)
763 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13) <<
"Group::" << x.gout.group[i]
764 <<
'&' <<
' ' << x.gout.name[i];
767 for (std::size_t i = 0; i < x.in.varname.size(); i++) {
769 x.out.varname.cbegin(), x.out.varname.cend(),
770 [in = x.in.varname[i]](
const auto& out) { return in == out; }))
772 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13 - 6) <<
"const Group::"
774 <<
'&' <<
' ' << x.in.varname[i];
778 for (std::size_t i = 0; i < x.gin.group.size(); i++)
779 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 13 - 6) <<
"const Group::" << x.gin.group[i] <<
'&'
780 <<
' ' << x.gin.name[i];
783 std::cout <<
')' <<
' ' <<
'{' <<
'\n';
786 std::cout <<
' ' <<
' ' << x.name <<
'(';
789 bool has_any =
false;
790 if (x.pass_workspace or x.agenda_method or
792 x.gin.group.cbegin(), x.gin.group.cend(),
793 [](
auto& g) { return g ==
"Agenda" or g ==
"ArrayOfAgenda"; }) or
794 std::any_of(x.in.varname.cbegin(), x.in.varname.cend(), [&](
auto& g) {
795 return artsname.varname_group.at(g).varname_group ==
"Agenda" or
796 artsname.varname_group.at(g).varname_group ==
"ArrayOfAgenda";
803 for (std::size_t i = 0; i < x.out.varname.size(); i++) {
804 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
806 std::cout << x.out.varname[i];
810 for (std::size_t i = 0; i < x.gout.name.size(); i++) {
811 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
813 std::cout << x.gout.name[i];
817 if (x.pass_wsv_names) {
818 for (std::size_t i = 0; i < x.gout.name.size(); i++) {
819 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
821 std::cout <<
"Group::String{\"" << x.gout.name[i] <<
"\"}";
826 for (std::size_t i = 0; i < x.in.varname.size(); i++) {
828 x.out.varname.cbegin(), x.out.varname.cend(),
829 [in = x.in.varname[i]](
const auto& out) { return in == out; }))
831 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
833 std::cout << x.in.varname[i];
837 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
838 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
840 std::cout << x.gin.name[i];
844 if (x.pass_wsv_names) {
845 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
846 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
848 std::cout <<
"Group::String{\"" << x.gin.name[i] <<
"\"}";
853 const bool has_verbosity =
854 std::any_of(x.in.varname.cbegin(), x.in.varname.cend(),
855 [](
auto& name) { return name ==
"verbosity"; });
858 if (not has_verbosity) {
859 if (has_any) std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 2 + 1);
861 std::cout <<
"Var::verbosity(ws).value()";
865 std::cout <<
')' <<
';' <<
'\n' <<
'}' <<
'\n' <<
'\n' <<
'\n';
870 std::cout <<
"#pragma clang diagnostic push\n";
871 std::cout <<
"#pragma clang diagnostic ignored \"-Wbraced-scalar-init\"\n";
872 std::cout <<
"namespace Method {\n";
875 std::cout <<
"} // namespace Method \n\n";
876 std::cout <<
"#pragma clang diagnostic pop\n";
880 std::cout <<
"namespace Method {\n";
884 if (x.agenda_method)
continue;
887 if (std::any_of(artsname.
group.cbegin(), artsname.
group.cend(),
888 [metname = x.name](
auto& y) {
889 return (y.first + String(
"Create")) == metname;
894 std::cout <<
"/*! " << x.desc <<
'\n';
895 for (
const auto&
a : x.authors) std::cout <<
"@author " <<
a <<
'\n';
897 "@param[in,out] Workspace ws - An ARTS workspace\n";
898 for (std::size_t i = 0; i < x.gout.name.size(); i++)
899 std::cout <<
"@param[out] " << x.gout.name[i] <<
" - " << x.gout.desc[i]
901 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
902 std::cout <<
"@param[in] " << x.gin.name[i] <<
" - " << x.gin.desc[i];
903 if (x.gin.hasdefs[i]) std::cout <<
" (default: " << x.gin.defs[i] <<
")";
906 std::cout <<
"\nUse the ARTS documentation to read more on how the "
907 "workspace is manipulated\n";
908 std::cout <<
"This interface function has been automatically generated\n";
910 <<
"@return MRecord to call this method\n";
911 std::cout <<
"*/" <<
'\n';
914 std::cout <<
"[[nodiscard]] inline\nGroup::Internal::MRecord " << x.name
915 <<
"(Workspace& ws [[maybe_unused]]";
918 for (std::size_t i = 0; i < x.gout.group.size(); i++) {
919 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 26);
920 std::cout <<
"Var::" << x.gout.group[i] <<
' '
925 for (std::size_t i = 0; i < x.gin.group.size(); i++) {
926 if (not x.gin.hasdefs[i]) {
927 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 26 - 6);
928 std::cout <<
"const Var::" << x.gin.group[i] <<
' '
934 for (std::size_t i = 0; i < x.gin.group.size(); i++) {
935 if (x.gin.hasdefs[i]) {
936 std::cout <<
',' <<
'\n' <<
spaces(x.name.size() + 26 - 6);
937 std::cout <<
"const Var::" << x.gin.group[i] <<
'&'
938 <<
' ' << x.gin.name[i] <<
'=' <<
"{}";
943 std::cout <<
')' <<
' ' <<
'{' <<
'\n';
946 if (x.gout.group.size() or x.gin.group.size()) std::cout <<
' ';
947 for (std::size_t i = 0; i < x.gout.group.size(); i++) {
948 std::cout <<
" if (" << x.gout.name[i]
949 <<
".islast()) {\n throw std::runtime_error(\""
950 << x.gout.name[i] <<
" needs to be a defined Workspace"
951 << x.gout.group[i] <<
" since it is output of " << x.name
954 for (std::size_t i = 0; i < x.gin.group.size(); i++) {
955 if (x.gin.hasdefs[i])
956 std::cout <<
" if (not " << x.gin.name[i] <<
".isnull() and "
958 <<
".islast()) {\n throw std::runtime_error(\""
959 << x.gin.name[i] <<
" needs to be a defined Workspace"
961 <<
" (or left default) since it is agenda input to " << x.name
964 std::cout <<
" if (" << x.gin.name[i]
965 <<
".islast()) {\n throw std::runtime_error(\""
966 << x.gin.name[i] <<
" needs to be a defined Workspace"
967 << x.gin.group[i] <<
" since it is agenda input to " << x.name
970 if (x.gout.group.size() or x.gin.group.size()) std::cout <<
'\n' <<
'\n';
972 for (std::size_t i = 0; i < x.gin.group.size(); i++) {
973 if (x.gin.hasdefs[i]) {
975 <<
" static const auto " << x.gin.name[i]
976 <<
"_default = Var::" << x.gin.group[i] <<
"Create(ws, "
977 << x.gin.defs[i] <<
",\n \"" << x.name <<
'_' << x.gin.name[i]
979 <<
"\",\n \"auto generated variable with default from method "
985 std::cout <<
" return Group::Internal::MRecord(" << x.pos <<
',' <<
'\n'
986 <<
spaces(34) <<
"Group::ArrayOfIndex(" <<
'{';
989 for (
unsigned long varpo : x.out.varpos) {
990 std::cout << varpo <<
',' <<
'\n' <<
spaces(34 + 21);
994 for (
const auto & i : x.gout.name) {
995 std::cout <<
"Group::Index(" << i <<
".pos())" <<
',' <<
'\n' <<
spaces(34 + 21);
997 std::cout <<
'}' <<
')' <<
',' <<
'\n' <<
spaces(34) <<
"Group::ArrayOfIndex("
1001 for (
unsigned long varpo : x.in.varpos) {
1002 std::cout << varpo <<
',' <<
'\n' <<
spaces(34 + 21);
1006 for (std::size_t i = 0; i < x.gin.name.size(); i++) {
1007 if (x.gin.hasdefs[i])
1008 std::cout << x.gin.name[i] <<
".isnull() ? Group::Index(" << x.gin.name[i]
1009 <<
"_default.pos()) :" <<
'\n' <<
spaces(34 + 21 + 12 + x.gin.name[i].size());
1010 std::cout <<
"Group::Index(" << x.gin.name[i] <<
".pos())" <<
',' <<
'\n' <<
spaces(34 + 21);
1013 std::cout <<
'}' <<
')' <<
',' <<
' ';
1016 std::cout <<
'\n' <<
spaces(34) <<
"Group::Internal::TokVal{" << x.gin.name[0]
1019 std::cout <<
'\n' <<
spaces(34) <<
"Group::Internal::TokVal{}";
1021 std::cout <<
',' <<
'\n' <<
spaces(34) <<
"Group::Agenda{}";
1024 std::cout <<
')' <<
';' <<
'\n' <<
'}' <<
'\n' <<
'\n' <<
'\n';
1026 std::cout <<
"} // namespace Method \n\n";
1030 std::cout <<
"namespace Execute { \n\n";
1032 std::cout <<
"/*! " << x.second.desc <<
'\n'
1033 <<
"@param[in,out] Workspace ws - An ARTS workspace\n"
1035 <<
"inline void " << x.first <<
"(Workspace& ws) {\n " << x.first
1037 for (
auto& name : x.second.outs) {
1038 std::cout <<
',' <<
'\n' <<
spaces(x.first.size() + 2 + 1 + 7) <<
"Var::" << name
1041 for (
auto& name : x.second.ins) {
1042 if (not std::any_of(x.second.outs.cbegin(), x.second.outs.cend(),
1043 [name](
auto& outname) { return name == outname; }))
1044 std::cout <<
',' <<
'\n' <<
spaces(x.first.size() + 2 + 1 + 7) <<
"Var::" << name
1047 std::cout <<
',' <<
'\n' <<
spaces(x.first.size() + 2 + 1 + 7) <<
"Var::" << x.first <<
"(ws).value());\n}\n\n";
1049 std::cout <<
"} // namespace Execute \n\n";
1053 std::cout <<
"namespace Define { \n";
1054 std::cout <<
"/*! Append Records to an agenda */\n";
1056 <<
"template <typename ... Records>\nvoid Append(Group::Agenda& ag, "
1057 "Records ... records) {\n"
1058 <<
" for (auto& x: { Group::Internal::MRecord(records)... })\n "
1059 "ag.push_back(x);\n}\n\n";
1061 if (artsname.
varname_group.at(x.first).varname_group ==
"ArrayOfAgenda")
1063 std::cout <<
"/*! " << x.second.desc <<
'\n'
1064 <<
"@param[in,out] Workspace ws - An ARTS workspace\n"
1065 <<
"@param[in] MRecords records - Any number of ARTS methods "
1066 "from AgendaMethod\n"
1068 <<
"template <typename ... Records> "
1069 <<
"\nvoid " << x.first
1070 <<
"(Workspace& ws, Records ... records) {\n"
1071 <<
" Var::" << x.first <<
"(ws).value().resize(0);\n"
1072 <<
" Var::" << x.first <<
"(ws).value().set_name(\"" << x.first
1074 <<
" Append(Var::" << x.first <<
"(ws).value(), records...);"
1076 <<
" Var::" << x.first
1077 <<
"(ws).value().check(ws, Var::verbosity(ws).value());\n}\n\n";
1079 std::cout <<
"} // namespace Define \n\n";
1083 std::cout <<
"/*! ARTS Agenda interaction namespace\n\n Will only be "
1084 "populated by namespaces.\n Users of the API can define their "
1085 "Agendas\n in the Agenda namespace\n*/\n";
1086 std::cout <<
"namespace Agenda {\n";
1090 std::cout <<
"} // namespace Agenda\n";
1094 std::cout <<
"namespace Species {\n";
1095 std::cout <<
" using namespace ::Species;\n";
1096 std::cout <<
"} // namespace Species \n\n";
1100 std::cout <<
"/*! Create a Workspace and set its main verbosity\n\n"
1101 <<
" @param[in] screen Screen verbosity\n"
1102 <<
" @param[in] file File verbosity\n"
1103 <<
" @param[in] agenda Agenda verbosity\n"
1104 <<
" @param[in] basename Default basename for output variables\n"
1105 <<
" @param[in] numthreads OpenMP thread count (defaults to max "
1106 "if invalid count)\n"
1107 <<
" @return Workspace a full ARTS Workspace\n"
1110 <<
"inline Workspace init(std::size_t screen=0, std::size_t file=0, "
1111 "std::size_t agenda=0, const Group::String& basename=\"arts\", "
1112 "[[maybe_unused]] int numthreads=0) {\n"
1114 " omp_set_num_threads(numthreads < 1 ? arts_omp_get_max_threads() : "
1115 "numthreads > arts_omp_get_max_threads() ? arts_omp_get_max_threads() "
1119 " define_wsv_group_names();\n"
1120 " Workspace::define_wsv_data();\n"
1121 " Workspace::define_wsv_map();\n"
1122 " define_md_data_raw();\n"
1123 " expand_md_data_raw_to_md_data();\n"
1124 " define_md_map();\n"
1125 " define_agenda_data();\n"
1126 " define_agenda_map();\n"
1127 " global_data::workspace_memory_handler.initialize();\n"
1130 " ws.initialize();\n"
1131 " Var::verbosity(ws).value().set_screen_verbosity(screen);\n"
1132 " Var::verbosity(ws).value().set_agenda_verbosity(agenda);\n"
1133 " Var::verbosity(ws).value().set_file_verbosity(file);\n"
1134 " Var::verbosity(ws).value().set_main_agenda(1);\n"
1136 " out_basename = basename;\n"
1139 " ws.context = \"\";\n"
1158 std::cout <<
"#ifndef autoarts_h\n"
1159 <<
"#define autoarts_h\n"
1164 std::cout <<
"namespace ARTS {\n";
1178 std::cout <<
"} // namespace::ARTS\n\n";
1180 std::cout <<
"#endif // autoarts_h\n";
void define_agenda_data()
void define_wsv_group_names()
Define the array of workspace variable group names.
static void define_wsv_data()
Define workspace variables.
static void define_wsv_map()
Map WSV names to indices.
static Array< WsvRecord > wsv_data
Global WSV data.
static map< String, Index > WsvMap
Global map associated with wsv_data.
void print_include_and_external()
void print_agenda_methods(const NameMaps &artsname)
std::vector< Method > methods()
std::pair< std::vector< std::string >, std::vector< bool > > fixed_defaults(const std::vector< std::string > &vargroups, const std::vector< std::string > &vardefaults)
void print_gin_methods(const NameMaps &artsname)
void print_methods(const NameMaps &artsname)
void print_full_methods(const NameMaps &artsname)
void print_agenda_define(const NameMaps &artsname)
void print_agenda_execute(const NameMaps &artsname)
std::map< std::string, AgendaData > agendas()
std::string spaces(std::size_t n)
void print_variables(const NameMaps &artsname)
std::map< std::string, Group > groups()
void print_agendas(const NameMaps &artsname)
void print_groups_and_namespaces(const NameMaps &artsname)
void print_species_identification()
void define_md_data_raw()
void define_md_map()
Define MdMap.
void expand_md_data_raw_to_md_data()
Expand supergeneric methods.
my_basic_string< char > String
The String type for ARTS.
const Array< MdRecord > md_data
Lookup information for workspace methods.
const map< String, Index > MdMap
The map associated with md_data.
const Array< AgRecord > agenda_data
The lookup information for the agendas.
const map< String, Index > WsvGroupMap
The map associated with wsv_group_names.
map< String, Index > AgendaMap
The map associated with agenda_data.
std::vector< std::string > outs
std::vector< std::string > ins
std::string varname_group
std::vector< std::string > group
std::vector< bool > hasdefs
std::vector< std::string > defs
std::vector< std::string > name
std::vector< std::string > desc
std::vector< std::string > group
std::vector< std::string > desc
std::vector< std::string > name
std::vector< std::size_t > varpos
std::vector< std::string > varname
std::vector< std::size_t > varpos
std::vector< std::string > varname
std::vector< std::string > authors
std::vector< std::size_t > inoutvarpos
std::vector< Method > methodname_method
std::map< std::string, AgendaData > agendaname_agenda
std::map< std::string, std::size_t > group
std::map< std::string, Group > varname_group