ARTS 2.5.9 (git: 825fa5f2)
methods_aux.cc
Go to the documentation of this file.
1/* Copyright (C) 2000-2012 Stefan Buehler <sbuehler@ltu.se>
2
3 This program is free software; you can redistribute it and/or modify it
4 under the terms of the GNU General Public License as published by the
5 Free Software Foundation; either version 2, or (at your option) any
6 later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12
13 You should have received a copy of the GNU General Public License
14 along with this program; if not, write to the Free Software
15 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 USA. */
17
30#include <algorithm>
31#include <map>
32#include "arts.h"
33#include "groups.h"
34#include "methods.h"
35#include "workspace_ng.h"
37#include "wsv_aux.h"
38
39namespace global_data {
41map<String, Index> MdMap;
43map<String, Index> MdRawMap;
45
51
52extern const Array<MdRecord> md_data_raw;
54} // namespace global_data
55
56void limit_line_length(ostream& os,
57 ostringstream& curline,
58 ostringstream& token,
59 const String& indent,
60 size_t linelen);
61
63
69MdRecord::MdRecord(const char* name,
70 const char* description,
71 const ArrayOfString& authors,
72 const ArrayOfString& output,
73 const ArrayOfString& gout,
74 const ArrayOfString& gouttype,
75 const ArrayOfString& goutdesc,
76 const ArrayOfString& input,
77 const ArrayOfString& gin,
78 const ArrayOfString& gintype,
79 const ArrayOfString& gindefault,
80 const ArrayOfString& gindesc,
81 bool set_method,
82 bool agenda_method,
83 bool uses_templates,
84 bool pass_workspace,
85 bool pass_wsv_names)
86 : mname(name),
87 mdescription(description),
88 mauthors(authors),
89 moutput(0),
90 mgout(gout),
91 mgouttype(0),
92 mgoutdesc(goutdesc),
93 minput(0),
94 mgin(gin),
95 mgintype(0),
96 mgindefault(gindefault),
97 mgindesc(gindesc),
98 mset_method(set_method),
99 magenda_method(agenda_method),
100 msupergeneric(false),
101 muses_templates(uses_templates),
102 mpass_workspace(pass_workspace),
103 mpass_wsv_names(pass_wsv_names),
104 mactual_groups("") {
105 // Initializing the various arrays with input data should now
106 // work correctly.
107
108 // Generic variable names, types and defaults must have the same number of
109 // elements. (Defaults specifies the default values associated with each
110 // generic input.)
111 ARTS_ASSERT(mgout.nelem() == gouttype.nelem());
112 ARTS_ASSERT(mgout.nelem() == goutdesc.nelem());
114 ARTS_ASSERT(mgin.nelem() == gintype.nelem());
115 ARTS_ASSERT(mgin.nelem() == gindesc.nelem());
116
117 // Check that GIN and GOUT don't contain duplicates
118 ArrayOfString gin_sorted = mgin;
119 std::sort(gin_sorted.begin(), gin_sorted.end());
120 ArrayOfString gout_sorted = mgout;
121 std::sort(gout_sorted.begin(), gout_sorted.end());
122
123 for (auto par = mgin.begin(); mgin.nelem() > 1 && par + 1 != mgin.end();
124 par++) {
125 if (*par == *(par + 1)) {
126 std::ostringstream os;
127 os << "Two input parameters by the same name are not allowed: \n";
128 os << "Method: " << mname << ", Parameter: " << *par;
129 throw std::runtime_error(os.str());
130 }
131 }
132
133 for (auto par = mgout.begin(); mgout.nelem() > 1 && par + 1 != mgout.end();
134 par++) {
135 if (*par == *(par + 1)) {
136 std::ostringstream os;
137 os << "Two output parameters by the same name are not allowed: \n";
138 os << "Method: " << mname << ", Parameter: " << *par;
139 throw std::runtime_error(os.str());
140 }
141 }
142
143 // Check that GIN and GOUT don't share parameter names
144 ArrayOfString gisect(gin_sorted.nelem());
145 auto it = std::set_intersection(gin_sorted.begin(),
146 gin_sorted.end(),
147 gout_sorted.begin(),
148 gout_sorted.end(),
149 gisect.begin());
150 gisect.resize(it - gisect.begin());
151
152 if (gisect.nelem() > 0) {
153 std::ostringstream os;
154 os << "Using the same name for a generic input and generic output variable is not allowed: \n";
155 os << "Method: " << mname << ", Parameter: ";
156 for (auto& gname : gisect) {
157 os << gname << " ";
158 }
159 throw std::runtime_error(os.str());
160 }
161
162 // Map the WSV names to indexes
163 moutput.resize(output.nelem());
164 for (Index j = 0; j < output.nelem(); ++j) {
165 moutput[j] = global_data::WsvMap.at(output[j]);
166 if (moutput[j] == -1) {
167 ostringstream os;
168 os << "Unknown WSV " << output[j] << " for output (parameter #" << j
169 << ") "
170 << "in WSM " << mname;
171 throw runtime_error(os.str());
172 }
173 }
174
175 minput.resize(input.nelem());
176 for (Index j = 0; j < input.nelem(); ++j) {
177 minput[j] = global_data::WsvMap.at(input[j]);
178 if (minput[j] == -1) {
179 ostringstream os;
180 os << "Unknown WSV " << input[j] << " for input (parameter #" << j << ") "
181 << "in WSM " << mname;
182 throw runtime_error(os.str());
183 }
184 }
185
186 // Map the group names to groups' indexes
187 mgoutspectype.resize(gouttype.nelem());
188 mgouttype.resize(gouttype.nelem());
189 for (Index j = 0; j < gouttype.nelem(); ++j) {
190 ArrayOfIndex types;
191 get_wsv_group_ids(types, gouttype[j]);
192
193 if (types.nelem() == 1) {
194 mgouttype[j] = types[0];
195 mgoutspectype[j].resize(0);
196 if (types[0] == get_wsv_group_id("Any") && !muses_templates) {
197 ostringstream os;
198 os << "WSM " << mname << " takes \"Any\" as input and\n"
199 << "therefore must be implemented as a template function.\n"
200 << "Pass USES_TEMPLATES(true) in methods.cc!";
201 throw runtime_error(os.str());
202 }
203 } else if (types.nelem() > 1) {
204 mgouttype[j] = get_wsv_group_id("Any");
205 mgoutspectype[j] = types;
206 } else {
207 ostringstream os;
208 os << "Unknown WSV Group " << gouttype[j] << " for generic output "
209 << "in WSM " << mname;
210 throw runtime_error(os.str());
211 }
212 }
213
214 mginspectype.resize(gintype.nelem());
215 mgintype.resize(gintype.nelem());
216 for (Index j = 0; j < gintype.nelem(); ++j) {
217 ArrayOfIndex types;
218 get_wsv_group_ids(types, gintype[j]);
219
220 if (types.nelem() == 1) {
221 mgintype[j] = get_wsv_group_id(gintype[j]);
222 mginspectype[j].resize(0);
223 if (types[0] == get_wsv_group_id("Any") && !muses_templates) {
224 ostringstream os;
225 os << "WSM " << mname << " defines \"Any\" as output and\n"
226 << "therefore must be implemented as a template function.\n"
227 << "Pass USES_TEMPLATES(true) in methods.cc!";
228 throw runtime_error(os.str());
229 }
230 } else if (types.nelem() > 1) {
231 mgintype[j] = get_wsv_group_id("Any");
232 mginspectype[j] = types;
233 } else {
234 ostringstream os;
235 os << "Unknown WSV Group " << gintype[j] << " for generic input "
236 << "in WSM " << mname;
237 throw runtime_error(os.str());
238 }
239 }
240
241 // Check that the number of types for all supergeneric variables are
242 // consistent
244 bool consistent = true;
245 Index nspecs = 0;
246 for (Index i = 0; consistent && i < mginspectype.nelem(); i++) {
247 if (mginspectype[0].nelem()) {
248 if (!nspecs)
249 nspecs = mginspectype[0].nelem();
250 else if (nspecs != mginspectype[0].nelem())
251 consistent = false;
252 }
253 }
254
255 for (Index i = 0; consistent && i < mgoutspectype.nelem(); i++) {
256 if (mgoutspectype[0].nelem()) {
257 if (!nspecs)
258 nspecs = mgoutspectype[0].nelem();
259 else if (nspecs != mgoutspectype[0].nelem())
260 consistent = false;
261 }
262 }
263 if (!consistent) {
264 ostringstream os;
265 os << "Inconsistent number of types given for supergeneric variables"
266 << endl
267 << "in WSM " << mname << "." << endl;
268 throw runtime_error(os.str());
269 }
270 }
271
272 // Find out if this method is supergeneric, and set the flag if
273 // yes:
274 const Index anyid = get_wsv_group_id("Any");
275 for (Index j = 0; j < mgouttype.nelem(); ++j)
276 if (anyid == mgouttype[j]) msupergeneric = true;
277 for (Index j = 0; j < mgintype.nelem(); ++j)
278 if (anyid == mgintype[j]) msupergeneric = true;
279
280 // Determine variables that are only input
281 minonly = minput; // Input
282 for (ArrayOfIndex::const_iterator j = moutput.begin(); j < moutput.end(); ++j)
283 for (ArrayOfIndex::iterator k = minonly.begin(); k < minonly.end(); ++k)
284 if (*j == *k) {
285 k = minonly.erase(k) - 1;
286 // We need the -1 here, otherwise due to the
287 // following increment we would miss the element
288 // behind the erased one, which is now at the
289 // position of the erased one.
290 }
291
292 // Determine variables that are input and output
293 minout.resize(0);
294 Index i = 0;
295 for (ArrayOfIndex::const_iterator j = moutput.begin(); j < moutput.end();
296 ++j, ++i)
297 for (ArrayOfIndex::const_iterator k = minput.begin(); k < minput.end(); ++k)
298 if (*j == *k) minout.push_back(i);
299
300 // Determine variables that are only output
301 moutonly = moutput; // Output
302 for (ArrayOfIndex::const_iterator j = minput.begin(); j < minput.end(); ++j)
303 for (ArrayOfIndex::iterator k = moutonly.begin(); k < moutonly.end(); ++k)
304 if (*j == *k) {
305 k = moutonly.erase(k) - 1;
306 // We need the -1 here, otherwise due to the
307 // following increment we would miss the element
308 // behind the erased one, which is now at the
309 // position of the erased one.
310 }
311}
312
314
324 const Index wsv_group_id_Any = get_wsv_group_id("Any");
325 // The group names, we need them for the expansion:
327
328 // Make sure they are initialized:
329 ARTS_ASSERT(0 != wsv_groups.nelem());
330
331 // Make sure that g is in the allowed range, which means
332 // 0<=g<wsv_groups.nelem() and g != Any_
333 ARTS_ASSERT(0 <= g);
334 ARTS_ASSERT(wsv_group_id_Any != g);
335 ARTS_ASSERT(g < wsv_groups.nelem());
336
337 // Make sure that this really is a supergeneric method:
339
340 // Modify the name:
341 // {
342 // ostringstream os;
343 // os << mname << "_sg_" << wsv_groups[g];
344 // mname = os.str();
345 // }
346
347 for (Index j = 0; j < mgouttype.nelem(); ++j)
348 if (wsv_group_id_Any == mgouttype[j]) mgouttype[j] = g;
349 for (Index j = 0; j < mgintype.nelem(); ++j)
350 if (wsv_group_id_Any == mgintype[j]) mgintype[j] = g;
351
352 // Set the field for the actual group:
353 mactual_groups = wsv_groups[g].name;
354}
355
357
367 // The group names, we need them for the expansion:
369
370 const Index wsv_group_id_Any = get_wsv_group_id("Any");
371
372 // Make sure that g is in the allowed range, which means
373 // 0<=g<wsv_groups.nelem() and g != Any_
374 ARTS_ASSERT(0 <= g);
375
376 // Make sure that this really is a supergeneric method:
378
379 // Modify the name:
380 // {
381 // ostringstream os;
382 // os << mname << "_sg_" << wsv_groups[g];
383 // mname = os.str();
384 // }
385
386 mactual_groups = "";
387 for (Index j = 0; j < mgouttype.nelem(); ++j)
388 if (wsv_group_id_Any == mgouttype[j]) {
389 mgouttype[j] = mgoutspectype[j][g];
390 // Set the field for the actual group:
391 mactual_groups += wsv_groups[mgoutspectype[j][g]].name;
392 }
393
394 for (Index j = 0; j < mgintype.nelem(); ++j)
395 if (wsv_group_id_Any == mgintype[j]) {
396 mgintype[j] = mginspectype[j][g];
397 // Set the field for the actual group:
398 mactual_groups += wsv_groups[mginspectype[j][g]].name;
399 }
400}
401
403
415
416 // The group names, we need them for the expansion:
418
419 const Index wsv_group_id_Any = get_wsv_group_id("Any");
420
421 // Make sure that they have been initialized:
422 ARTS_ASSERT(0 != wsv_groups.nelem());
423
424 // Reset md_data, just in case:
425 md_data.resize(0);
426
427 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
428 const MdRecord& mdd = md_data_raw[i];
429
430 if (!mdd.Supergeneric()) {
431 md_data.push_back(mdd);
432 } else {
433 // Special treatment for supergeneric methods:
434
435 // Check if the method is really supergeneric or just valid
436 // for certain types.
437
438 if ((mdd.GInSpecType().nelem() && mdd.GInSpecType()[0].nelem()) ||
439 (mdd.GOutSpecType().nelem() && mdd.GOutSpecType()[0].nelem())) {
440 Index max = 0;
441 if (mdd.GInSpecType().nelem()) max = mdd.GInSpecType()[0].nelem();
442 if (mdd.GOutSpecType().nelem() && mdd.GOutSpecType()[0].nelem() > max)
443 max = mdd.GOutSpecType()[0].nelem();
444
445 for (Index k = 0; k < max; k++) {
446 MdRecord mdlocal = mdd;
447
449
450 md_data.push_back(mdlocal);
451 }
452 } else {
453 for (Index j = 0; j < wsv_groups.nelem(); ++j) {
454 // Any_ itself is also a group, but we don't want to
455 // create a record for Any_!
456 if (wsv_group_id_Any != j) {
457 // Not a reference but a copy this time, since we
458 // have to manipulate this.
459 MdRecord mdlocal = mdd;
460
461 mdlocal.subst_any_with_group(j);
462
463 md_data.push_back(mdlocal);
464 }
465 }
466 }
467 }
468 }
469}
470
472
476 // md_data is constant here and should never be changed
478 using global_data::MdMap;
480
481 // Check that md_data and wsv_groups have already be defined:
482 ARTS_ASSERT(0 != md_data.nelem());
483 ARTS_ASSERT(0 != wsv_groups.nelem());
484
485 for (Index i = 0; i < md_data.nelem(); ++i) {
486 const MdRecord& mdd = md_data[i];
487
488 // For supergeneric methods, add group to method name
489 String methodname;
490 ostringstream os;
491 if (mdd.Supergeneric()) {
492 os << mdd.Name() << "_sg_" << mdd.ActualGroups();
493 } else {
494 os << mdd.Name();
495 }
496 methodname = os.str();
497
498 MdMap[methodname] = i;
499 }
500}
501
503
514
515 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
516 MdRawMap[md_data_raw[i].Name()] = i;
517 }
518}
519
521 const String& indent,
522 const size_t linelen,
523 const size_t offset) {
524 bool fit = true;
525 String out;
526 String token;
527 size_t currentlinelength = offset;
528 for (size_t i = 0; i < s.length(); i++) {
529 if (s[i] == '\n') s[i] = ' ';
530 token += s[i];
531 if (s[i] == ' ') {
532 if (currentlinelength + token.length() > linelen) {
533 out += '\n' + indent;
534 currentlinelength = indent.length();
535 fit = false;
536 }
537 out += token;
538 currentlinelength += token.length();
539 token = "";
540 }
541 }
542
543 if (token.length()) {
544 if (currentlinelength + token.length() > linelen) {
545 out += '\n' + indent;
546 fit = false;
547 }
548 out += token;
549 }
550 s = out;
551 return fit;
552}
553
555 Index pos;
556 Index pos2;
557
558 // Find the end of the short WSV description
559 pos = desc.find(".\n");
560 pos2 = desc.find(". ");
561 if (pos == String::npos || (pos2 != String::npos && pos2 < pos)) pos = pos2;
562 if (pos == String::npos) pos = desc.find("\n");
563 if (pos != String::npos)
564 s = desc.substr(0, pos + 1);
565 else
566 s = desc;
567
568 // Replace any newlines inside the description with spaces
569 while ((pos = s.find("\n")) != String::npos) {
570 s[pos] = ' ';
571 }
572}
573
574ostream& MdRecord::PrintTemplate(ostream& os, bool show_description) const {
576
577 if (show_description) {
578 // FIXME: Print description String!
579 }
580
581 os << Name();
582
583 // Is this a generic method? -- Then we need round braces.
584 if (0 != GOutType().nelem() + GInType().nelem()) {
585 // First entry needs to comma before:
586 bool first = true;
587
588 os << '(';
589
590 for (Index i = 0; i < GOutType().nelem(); ++i) {
591 if (first)
592 first = false;
593 else
594 os << ",\n";
595
596 os << wsv_groups[GOutType()[i]];
597 }
598
599 for (Index i = 0; i < GInType().nelem(); ++i) {
600 if (first)
601 first = false;
602 else
603 os << ",\n";
604
605 os << wsv_groups[GInType()[i]];
606 }
607
608 os << ')';
609 }
610
611 // Now the keywords:
612
613 os << '{';
614
615 // Determine the length of the longest keyword:
616 Index maxsize = 0;
617 for (Index i = 0; i < GIn().nelem(); ++i)
618 if (GIn()[i].nelem() > maxsize) maxsize = GIn()[i].nelem();
619
620 for (Index i = 0; i < GIn().nelem(); ++i) {
621 os << "\t" << setw((int)maxsize) << GIn()[i] << " = \n";
622 }
623
624 os << '}';
625
626 return os;
627}
628
630
635void limit_line_length(ostream& os,
636 ostringstream& curline,
637 ostringstream& token,
638 const String& indent,
639 size_t linelen) {
640 if (indent.length() + curline.str().length() + token.str().length() >
641 linelen) {
642 os << curline.str() << endl << indent;
643 curline.str("");
644 }
645 curline << token.str();
646 token.str("");
647}
648
650ostream& operator<<(ostream& os, const MdRecord& mdr) {
652 bool first;
653 ostringstream buf;
654 ostringstream param;
655 String indent = "";
656 const size_t linelen = 68;
657 bool fit;
658 size_t lastlen;
659
660 os << "\n*-------------------------------------------------------------------*\n"
661 << "Workspace method = " << mdr.Name()
662 << "\n---------------------------------------------------------------------\n"
663 << "\n"
664 << mdr.Description() << "\n";
665
666 if (mdr.Description()[mdr.Description().nelem() - 1] != '\n') {
667 os << "\n";
668 }
669
670 // Print the method's synopsis
671 while (indent.length() < mdr.Name().length() + 2) indent += ' ';
672
673 os << "\nSynopsis:\n\n";
674 buf << mdr.Name() << "( ";
675 first = true;
676 for (Index i = 0; i < mdr.Out().nelem(); ++i) {
677 if (first)
678 first = false;
679 else
680 buf << ", ";
681 param << global_data::wsv_data[mdr.Out()[i]].Name();
682
683 limit_line_length(os, buf, param, indent, linelen);
684 }
685
686 for (Index i = 0; i < mdr.GOutType().nelem(); ++i) {
687 if (first)
688 first = false;
689 else
690 buf << ", ";
691 if (mdr.GOut()[i].length())
692 param << mdr.GOut()[i];
693 else
694 param << "gout" << i;
695
696 limit_line_length(os, buf, param, indent, linelen);
697 }
698
699 const ArrayOfIndex& inonly = mdr.InOnly();
700 for (Index i = 0; i < inonly.nelem(); ++i) {
701 if (first)
702 first = false;
703 else
704 buf << ", ";
705 param << global_data::wsv_data[inonly[i]].Name();
706
707 limit_line_length(os, buf, param, indent, linelen);
708 }
709
710 for (Index i = 0; i < mdr.GInType().nelem(); ++i) {
711 if (first)
712 first = false;
713 else
714 buf << ", ";
715 if (mdr.GIn()[i].length()) {
716 param << mdr.GIn()[i];
717 } else {
718 param << "gin" << i;
719 }
720
721 limit_line_length(os, buf, param, indent, linelen);
722 }
723 if (buf.str().length()) os << buf.str();
724
725 os << " )\n\n\n";
726
727 {
728 bool is_first_author = true;
729 for (Index i = 0; i < mdr.Authors().nelem(); i++) {
730 if (is_first_author) {
731 os << "Authors: ";
732 is_first_author = false;
733 } else
734 os << ", ";
735
736 os << mdr.Authors()[i];
737 }
738 os << "\n";
739 }
740
741 os << "\n\nVariables:\n\n";
742
743 // os << "\n-----\nName = " << mdr.Name() << '\n\n'
744 // << "Description =\n" << mdr.Description() << "\n\n";
745
746 // Out:
747 indent = String(6);
748 String desc;
749 for (Index i = 0; i < mdr.Out().nelem(); ++i) {
750 buf.str("");
751 buf << "OUT ";
752
753 buf << global_data::wsv_data[mdr.Out()[i]].Name();
754 buf << " (";
755 buf << wsv_groups[global_data::wsv_data[mdr.Out()[i]].Group()];
756 buf << "): ";
757
759 global_data::wsv_data[mdr.Out()[i]].Description());
760
761 if (buf.str().length() + desc.length() > linelen) {
762 format_paragraph(desc, indent, linelen);
763 buf << endl << indent << desc;
764 } else {
765 buf << desc;
766 }
767
768 os << buf.str() << endl;
769 }
770
771 for (Index i = 0; i < mdr.GOut().nelem(); ++i) {
772 buf.str("");
773 buf << "GOUT " << mdr.GOut()[i] << " (";
774 if (mdr.GOutType()[i] == get_wsv_group_id("Any") &&
775 mdr.GOutSpecType()[i].nelem()) {
776 bool firstarg = true;
777 for (Index j = 0; j < mdr.GOutSpecType()[i].nelem(); j++) {
778 if (!firstarg)
779 buf << ", ";
780 else
781 firstarg = false;
782 buf << wsv_groups[mdr.GOutSpecType()[i][j]];
783 }
784 } else {
785 buf << wsv_groups[mdr.GOutType()[i]];
786 }
787
788 buf << "): ";
789 desc = buf.str();
790 lastlen = desc.length();
791 fit = format_paragraph(desc, indent, linelen);
792 buf.str("");
793 os << desc;
794
795 desc = mdr.GOutDescription()[i];
796 if (!fit) {
797 format_paragraph(desc, indent, linelen);
798 buf << endl << indent << desc;
799 } else if (lastlen + desc.length() > linelen) {
800 format_paragraph(desc, indent, linelen, lastlen);
801 buf << endl << desc;
802 } else {
803 buf << desc;
804 }
805
806 os << buf.str() << endl;
807 }
808
809 for (Index i = 0; i < mdr.In().nelem(); ++i) {
810 buf.str("");
811 buf << "IN ";
812
813 buf << global_data::wsv_data[mdr.In()[i]].Name();
814 buf << " (";
815 buf << wsv_groups[global_data::wsv_data[mdr.In()[i]].Group()];
816 buf << "): ";
817
819 global_data::wsv_data[mdr.In()[i]].Description());
820
821 if (buf.str().length() + desc.length() > linelen) {
822 format_paragraph(desc, indent, linelen, indent.length());
823 buf << endl << indent << desc;
824 } else {
825 buf << desc;
826 }
827
828 os << buf.str() << endl;
829 }
830
831 for (Index i = 0; i < mdr.GIn().nelem(); ++i) {
832 buf.str("");
833 buf << "GIN " << mdr.GIn()[i] << " (";
834 if (mdr.GInType()[i] == get_wsv_group_id("Any") &&
835 mdr.GInSpecType()[i].nelem()) {
836 bool firstarg = true;
837 for (Index j = 0; j < mdr.GInSpecType()[i].nelem(); j++) {
838 if (!firstarg)
839 buf << ", ";
840 else
841 firstarg = false;
842 buf << wsv_groups[mdr.GInSpecType()[i][j]];
843 }
844 } else {
845 buf << wsv_groups[mdr.GInType()[i]];
846 }
847
848 if (mdr.GInDefault()[i] != NODEF) {
849 buf << ", Default: ";
850 if (mdr.GInType()[i] == get_wsv_group_id("String")) {
851 buf << "\"" << mdr.GInDefault()[i] << "\"";
852 } else {
853 buf << mdr.GInDefault()[i];
854 }
855 }
856
857 buf << "): ";
858 desc = buf.str();
859 lastlen = desc.length();
860 fit = format_paragraph(desc, indent, linelen);
861 buf.str("");
862 os << desc;
863
864 desc = mdr.GInDescription()[i];
865 if (!fit) {
866 format_paragraph(desc, indent, linelen);
867 buf << endl << indent << desc;
868 } else if (lastlen + desc.length() > linelen) {
869 format_paragraph(desc, indent, linelen, indent.length());
870 buf << endl << indent << desc;
871 } else {
872 buf << desc;
873 }
874
875 os << buf.str() << endl;
876 }
877
878 os << "\n*-------------------------------------------------------------------*\n";
879
880 return os;
881}
base max(const Array< base > &x)
Max function.
Definition: array.h:145
The global header file for ARTS.
This can be used to make arrays out of anything.
Definition: array.h:48
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
All information for one workspace method.
Definition: methods.h:38
ArrayOfIndex mgouttype
Generic Workspace Output Type.
Definition: methods.h:153
ArrayOfArrayOfIndex mginspectype
Generic Workspace Input Types (Contains the valid types if the method.
Definition: methods.h:173
bool muses_templates
Flag, whether method implementation relies on templates.
Definition: methods.h:216
const ArrayOfIndex & In() const
Definition: methods.h:93
ArrayOfIndex moutput
Workspace Output.
Definition: methods.h:147
String mactual_groups
The actual groups of a supergeneric method.
Definition: methods.h:237
const String & Name() const
Definition: methods.h:85
void subst_any_with_specific_group(Index g)
Expand supergeneric record for given Index in GOutSpecType and GInSpecType.
Definition: methods_aux.cc:366
const ArrayOfIndex & InOnly() const
Definition: methods.h:99
const ArrayOfIndex & GOutType() const
Definition: methods.h:90
const Array< String > & GOutDescription() const
Definition: methods.h:92
const String & ActualGroups() const
Definition: methods.h:108
String mname
The name of this method.
Definition: methods.h:138
const Array< String > & GInDefault() const
Definition: methods.h:97
MdRecord()
Default constructor.
Definition: methods.h:41
ArrayOfIndex minout
Indexes of Input-Output variables.
Definition: methods.h:188
const ArrayOfArrayOfIndex & GInSpecType() const
Definition: methods.h:96
ArrayOfString mgindefault
Generic Workspace Input Defaults.
Definition: methods.h:176
const String & Description() const
Definition: methods.h:86
const ArrayOfString & GOut() const
Definition: methods.h:89
ArrayOfIndex minput
Workspace Input.
Definition: methods.h:163
ArrayOfIndex mgintype
Generic Workspace Input.
Definition: methods.h:169
void subst_any_with_group(Index g)
Expand supergeneric record for given group.
Definition: methods_aux.cc:323
ArrayOfIndex moutonly
Indexes of Output-only variables.
Definition: methods.h:185
const Array< String > & GInDescription() const
Definition: methods.h:98
friend void subst_any_with_group(MdRecord &mdd, Index g)
ArrayOfIndex minonly
Indexes of Input-only variables.
Definition: methods.h:182
bool Supergeneric() const
Definition: methods.h:104
ostream & PrintTemplate(ostream &os, bool show_description=true) const
Print method template for the control file.
Definition: methods_aux.cc:574
const ArrayOfString & Authors() const
Definition: methods.h:87
ArrayOfString mgin
Generic Workspace Input Names.
Definition: methods.h:166
const ArrayOfArrayOfIndex & GOutSpecType() const
Definition: methods.h:91
const ArrayOfIndex & Out() const
Definition: methods.h:88
const ArrayOfIndex & GInType() const
Definition: methods.h:95
ArrayOfString mgout
Generic Workspace Output Names.
Definition: methods.h:150
ArrayOfArrayOfIndex mgoutspectype
Generic Workspace Output Types (Contains the valid types if the method.
Definition: methods.h:157
const ArrayOfString & GIn() const
Definition: methods.h:94
bool msupergeneric
Flag, whether this method is supergeneric.
Definition: methods.h:209
Index nelem() const
Definition: mystring.h:189
static const Index npos
Define npos:
Definition: mystring.h:209
#define DEBUG_ONLY(...)
Definition: debug.h:51
#define ARTS_ASSERT(condition,...)
Definition: debug.h:82
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
Definition: groups.cc:360
void get_wsv_group_ids(ArrayOfIndex &ids, String name)
Returns list of ids of the given group names.
Definition: groups.cc:367
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Declaration of the class MdRecord.
#define NODEF
Definition: methods.h:35
void define_md_raw_map()
Define MdRawMap.
Definition: methods_aux.cc:511
void get_short_wsv_description(String &s, const String &desc)
Definition: methods_aux.cc:554
void define_md_map()
Define MdMap.
Definition: methods_aux.cc:475
void expand_md_data_raw_to_md_data()
Expand supergeneric methods.
Definition: methods_aux.cc:412
void limit_line_length(ostream &os, ostringstream &curline, ostringstream &token, const String &indent, size_t linelen)
Limit length of output.
Definition: methods_aux.cc:635
ostream & operator<<(ostream &os, const MdRecord &mdr)
Output operator for MdRecord.
Definition: methods_aux.cc:650
bool format_paragraph(String &s, const String &indent, const size_t linelen, const size_t offset)
Definition: methods_aux.cc:520
my_basic_string< char > String
The String type for ARTS.
Definition: mystring.h:216
const ArrayOfGroupRecord wsv_groups
The names associated with Wsv groups as Strings.
Definition: global_data.h:91
const Array< MdRecord > md_data_raw
Lookup information for workspace methods.
Definition: methods.cc:42
Array< WsvRecord > wsv_data
Definition: workspace.cc:41
const Array< MdRecord > md_data
Lookup information for workspace methods.
Definition: methods_aux.cc:50
std::map< String, Index > WsvMap
Definition: workspace.cc:43
const map< String, Index > MdMap
The map associated with md_data.
Definition: methods_aux.cc:41
const map< String, Index > MdRawMap
The map associated with md_data_raw.
Definition: methods_aux.cc:43
This file contains the Workspace class.
Auxiliary header stuff related to workspace variable groups.