ARTS 2.5.9 (git: 825fa5f2)
main.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
31#include "arts.h"
32#include <memory>
33
34#ifdef ENABLE_DOCSERVER
35#include <unistd.h>
36#endif
37
38#include <algorithm>
39#include <chrono>
40#include <filesystem>
41#include <map>
42
43#include "absorption.h"
44#include "agenda_record.h"
45#include "arts_omp.h"
46#include "auto_md.h"
47#include "docserver.h"
48#include "exceptions.h"
49#include "file.h"
50#include "global_data.h"
51#include "messages.h"
52#include "methods.h"
53#include "mystring.h"
54#include "parameters.h"
55#include "parser.h"
57#include "workspace.h"
58#include "workspace_ng.h"
59#include "wsv_aux.h"
60#include "wsv_aux_operator.h"
61
64 cerr << "Try `arts --help' for help.\n";
65 arts_exit();
66}
67
83
84 if (-1 == r) {
85 // Reporting was not specified, set default. (No output from
86 // agendas (except main of course), only the important stuff to
87 // the screen, nothing to the file.)
91 } else {
92 // Reporting was specified. Check consistency and set report
93 // level accordingly.
94
95 // Separate the three digits:
99
100 if (!verbosity_at_launch.valid()) {
101 cerr << "Illegal value specified for --reporting (-r).\n"
102 << "The specified value is " << r << ", which would be\n"
103 << "interpreted as:\n"
104 << "Verbosity for agendas: "
106 << "Verbosity for screen: "
108 << "Verbosity for report file: "
110 << "Only values of 0-3 are allowed for each verbosity.\n";
111 arts_exit();
112 }
113 }
114}
115
123void option_methods(Workspace& workspace, const String& methods) {
124 // Make global data visible:
126 extern const Parameters parameters;
128
129 // This is used to count the number of matches to a query, so
130 // that `none' can be output if necessary
131 Index hitcount;
132
133 // First check if the user gave the special name `all':
134
135 if ("all" == methods) {
136 if (!parameters.plain) {
137 cout
138 << "\n*-------------------------------------------------------------------*\n"
139 << "Complete list of ARTS workspace methods:\n"
140 << "---------------------------------------------------------------------\n";
141 }
142 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
143 if (!parameters.plain) cout << "- ";
144 cout << md_data_raw[i].Name() << "\n";
145 }
146
147 if (!parameters.plain)
148 cout
149 << "*-------------------------------------------------------------------*\n\n";
150
151 return;
152 }
153
154 // Ok, so the user has probably specified a workspace variable or
155 // workspace variable group.
156
157 // Check if the user gave the name of a specific variable.
158 auto mi = workspace.WsvMap_ptr->find(methods);
159 if (mi != workspace.WsvMap_ptr->end()) {
160 // If we are here, then the given name matches a variable.
161 Index wsv_key = mi->second;
162
163 // List generic methods:
164 hitcount = 0;
165 cout
166 << "\n*-------------------------------------------------------------------*\n"
167 << "Generic and supergeneric methods that can generate "
168 << (*workspace.wsv_data_ptr)[wsv_key].Name() << ":\n"
169 << "---------------------------------------------------------------------\n";
170 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
171 // Get handle on method record:
172 const MdRecord& mdd = md_data_raw[i];
173
174 // This if statement checks whether GOutType, the list
175 // of output variable types contains the group of the
176 // requested variable.
177 // The else clause picks up methods with supergeneric input.
178 if (count(mdd.GOutType().begin(),
179 mdd.GOutType().end(),
180 (*workspace.wsv_data_ptr)[wsv_key].Group())) {
181 cout << "- " << mdd.Name() << "\n";
182 ++hitcount;
183 } else if (count(mdd.GOutType().begin(),
184 mdd.GOutType().end(),
185 get_wsv_group_id("Any"))) {
186 for (Index j = 0; j < mdd.GOutType().nelem(); j++) {
187 if (mdd.GOutType()[j] == get_wsv_group_id("Any")) {
188 if (mdd.GOutSpecType()[j].nelem()) {
189 if (count(mdd.GOutSpecType()[j].begin(),
190 mdd.GOutSpecType()[j].end(),
191 (*workspace.wsv_data_ptr)[wsv_key].Group())) {
192 cout << "- " << mdd.Name() << "\n";
193 ++hitcount;
194 }
195 } else {
196 cout << "- " << mdd.Name() << "\n";
197 ++hitcount;
198 }
199 }
200 }
201 }
202 }
203 if (0 == hitcount) cout << "none\n";
204
205 // List specific methods:
206 hitcount = 0;
207 cout
208 << "\n---------------------------------------------------------------------\n"
209 << "Specific methods that can generate "
210 << (*workspace.wsv_data_ptr)[wsv_key].Name() << ":\n"
211 << "---------------------------------------------------------------------\n";
212 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
213 // Get handle on method record:
214 const MdRecord& mdd = md_data_raw[i];
215
216 // This if statement checks whether Output, the list
217 // of output variables contains the workspace
218 // variable key.
219 if (count(mdd.Out().begin(), mdd.Out().end(), wsv_key)) {
220 cout << "- " << mdd.Name() << "\n";
221 ++hitcount;
222 }
223 }
224 if (0 == hitcount) cout << "none\n";
225
226 cout
227 << "*-------------------------------------------------------------------*\n\n";
228
229 return;
230 }
231
232 // Check if the user gave the name of a variable group.
233
234 // We use the find algorithm from the STL to do this. It
235 // returns an iterator, so to get the index we take the
236 // difference to the begin() iterator.
237 Index group_key =
238 find(wsv_groups.begin(), wsv_groups.end(), methods) -
239 wsv_groups.begin();
240
241 // group_key == wsv_goup_names.nelem() indicates that a
242 // group with this name was not found.
243 if (group_key != wsv_groups.nelem()) {
244 // List generic methods:
245 hitcount = 0;
246 cout
247 << "\n*-------------------------------------------------------------------*\n"
248 << "Generic and supergeneric methods that can generate variables of group "
249 << wsv_groups[group_key] << ":\n"
250 << "---------------------------------------------------------------------\n";
251 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
252 // Get handle on method record:
253 const MdRecord& mdd = md_data_raw[i];
254
255 // This if statement checks whether GOutType, the list
256 // of output variable types contains the
257 // requested group.
258 // The else clause picks up methods with supergeneric input.
259 if (count(mdd.GOutType().begin(), mdd.GOutType().end(), group_key)) {
260 cout << "- " << mdd.Name() << "\n";
261 ++hitcount;
262 } else if (count(mdd.GOutType().begin(),
263 mdd.GOutType().end(),
264 get_wsv_group_id("Any"))) {
265 for (Index j = 0; j < mdd.GOutType().nelem(); j++) {
266 if (mdd.GOutType()[j] == get_wsv_group_id("Any")) {
267 if (mdd.GOutSpecType()[j].nelem()) {
268 if (count(mdd.GOutSpecType()[j].begin(),
269 mdd.GOutSpecType()[j].end(),
270 group_key)) {
271 cout << "- " << mdd.Name() << "\n";
272 ++hitcount;
273 }
274 } else {
275 cout << "- " << mdd.Name() << "\n";
276 ++hitcount;
277 }
278 }
279 }
280 }
281 }
282 if (0 == hitcount) cout << "none\n";
283
284 cout
285 << "*-------------------------------------------------------------------*\n\n";
286
287 return;
288 }
289
290 // If we are here it means that what the user specified is neither
291 // `all', nor a variable, nor a variable group.
292 cerr << "The name " << methods << " matches neither `all',\n"
293 << "nor the name of a workspace variable, nor the name\n"
294 << "of a workspace variable group.\n";
295 arts_exit();
296}
297
305void option_input(const String& input) {
306 // Make global data visible:
309
310 // Ok, so the user has probably specified a workspace variable or
311 // workspace variable group.
312
313 // Check if the user gave the name of a specific variable.
314 auto mi = global_data::WsvMap.find(input);
315 if (mi != global_data::WsvMap.end()) {
316 // This is used to count the number of matches to a query, so
317 // that `none' can be output if necessary
318 Index hitcount = 0;
319
320 // If we are here, then the given name matches a variable.
321 Index wsv_key = mi->second;
322
323 // List generic methods:
324 cout
325 << "\n*-------------------------------------------------------------------*\n"
326 << "Generic and supergeneric methods that can use "
327 << global_data::wsv_data[wsv_key].Name() << ":\n"
328 << "---------------------------------------------------------------------\n";
329 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
330 // Get handle on method record:
331 const MdRecord& mdd = md_data_raw[i];
332
333 // This if statement checks whether GInType, the list
334 // of input variable types contains the group of the
335 // requested variable.
336 // The else clause picks up methods with supergeneric input.
337 if (count(mdd.GInType().begin(),
338 mdd.GInType().end(),
339 global_data::wsv_data[wsv_key].Group())) {
340 cout << "- " << mdd.Name() << "\n";
341 ++hitcount;
342 } else if (count(mdd.GInType().begin(),
343 mdd.GInType().end(),
344 get_wsv_group_id("Any"))) {
345 for (Index j = 0; j < mdd.GInType().nelem(); j++) {
346 if (mdd.GInType()[j] == get_wsv_group_id("Any")) {
347 if (mdd.GInSpecType()[j].nelem()) {
348 if (count(mdd.GInSpecType()[j].begin(),
349 mdd.GInSpecType()[j].end(),
350 global_data::wsv_data[wsv_key].Group())) {
351 cout << "- " << mdd.Name() << "\n";
352 ++hitcount;
353 }
354 } else {
355 cout << "- " << mdd.Name() << "\n";
356 ++hitcount;
357 }
358 }
359 }
360 }
361 }
362 if (0 == hitcount) cout << "none\n";
363
364 // List specific methods:
365 hitcount = 0;
366 cout
367 << "\n---------------------------------------------------------------------\n"
368 << "Specific methods that require "
369 << global_data::wsv_data[wsv_key].Name() << ":\n"
370 << "---------------------------------------------------------------------\n";
371 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
372 // Get handle on method record:
373 const MdRecord& mdd = md_data_raw[i];
374
375 // This if statement checks whether Output, the list
376 // of output variables contains the workspace
377 // variable key.
378 if (count(mdd.In().begin(), mdd.In().end(), wsv_key)) {
379 cout << "- " << mdd.Name() << "\n";
380 ++hitcount;
381 }
382 }
383 if (0 == hitcount) cout << "none\n";
384
385 cout
386 << "*-------------------------------------------------------------------*\n\n";
387
388 return;
389 }
390
391 // Check if the user gave the name of a variable group.
392
393 // We use the find algorithm from the STL to do this. It
394 // returns an iterator, so to get the index we take the
395 // difference to the begin() iterator.
396 Index group_key =
397 find(wsv_groups.begin(), wsv_groups.end(), input) -
398 wsv_groups.begin();
399
400 // group_key == wsv_goup_names.nelem() indicates that a
401 // group with this name was not found.
402 if (group_key != wsv_groups.nelem()) {
403 // This is used to count the number of matches to a query, so
404 // that `none' can be output if necessary
405 Index hitcount = 0;
406
407 // List generic methods:
408 cout
409 << "\n*-------------------------------------------------------------------*\n"
410 << "Generic and supergeneric methods that require a variable of group "
411 << wsv_groups[group_key] << ":\n"
412 << "---------------------------------------------------------------------\n";
413 for (Index i = 0; i < md_data_raw.nelem(); ++i) {
414 // Get handle on method record:
415 const MdRecord& mdd = md_data_raw[i];
416
417 // This if statement checks whether GOutType, the list
418 // of output variable types contains the
419 // requested group.
420 // The else clause picks up methods with supergeneric input.
421 if (count(mdd.GInType().begin(), mdd.GInType().end(), group_key)) {
422 cout << "- " << mdd.Name() << "\n";
423 ++hitcount;
424 } else if (count(mdd.GInType().begin(),
425 mdd.GInType().end(),
426 get_wsv_group_id("Any"))) {
427 for (Index j = 0; j < mdd.GInType().nelem(); j++) {
428 if (mdd.GInType()[j] == get_wsv_group_id("Any")) {
429 if (mdd.GInSpecType()[j].nelem()) {
430 if (count(mdd.GInSpecType()[j].begin(),
431 mdd.GInSpecType()[j].end(),
432 group_key)) {
433 cout << "- " << mdd.Name() << "\n";
434 ++hitcount;
435 }
436 } else {
437 cout << "- " << mdd.Name() << "\n";
438 ++hitcount;
439 }
440 }
441 }
442 }
443 }
444 if (0 == hitcount) cout << "none\n";
445
446 cout
447 << "*-------------------------------------------------------------------*\n\n";
448
449 return;
450 }
451
452 // If we are here it means that what the user specified is neither
453 // a variable nor a variable group.
454 cerr << "The name " << input << " matches neither the name of a\n"
455 << "workspace variable, nor the name of a workspace variable group.\n";
456 arts_exit();
457}
458
466void option_workspacevariables(const String& workspacevariables) {
467 // Make global data visible:
469 using global_data::MdMap;
470 extern const Parameters parameters;
472
473 // This is used to count the number of matches to a query, so
474 // that `none' can be output if necessary
475 Index hitcount;
476
477 // First check for `all':
478
479 if ("all" == workspacevariables) {
480 if (!parameters.plain) {
481 cout
482 << "\n*-------------------------------------------------------------------*\n"
483 << "Complete list of ARTS workspace variables:\n"
484 << "---------------------------------------------------------------------\n";
485 }
486
487 for (Index i = 0; i < global_data::wsv_data.nelem(); ++i) {
488 if (!parameters.plain) cout << "- ";
489 cout << global_data::wsv_data[i].Name() << "\n";
490 }
491
492 if (!parameters.plain)
493 cout
494 << "*-------------------------------------------------------------------*\n\n";
495 return;
496 }
497
498 // Now check if the user gave the name of a method.
499 auto mi = MdMap.find(workspacevariables);
500 if (mi != MdMap.end()) {
501 // If we are here, then the given name matches a method.
502 // Assign the data record for this method to a local
503 // variable for easier access:
504 const MdRecord& mdr = md_data[mi->second];
505
506 // List generic variables required by this method.
507 hitcount = 0;
508 cout
509 << "\n*-------------------------------------------------------------------*\n"
510 << "Generic workspace variables required by " << mdr.Name()
511 << " are of type:\n"
512 << "---------------------------------------------------------------------\n";
513 for (Index i = 0; i < mdr.GInType().nelem(); ++i) {
514 cout << "- " << wsv_groups[mdr.GInType()[i]] << "\n";
515 ++hitcount;
516 }
517 if (0 == hitcount) cout << "none\n";
518
519 // List specific variables required by this method.
520 hitcount = 0;
521 cout
522 << "\n---------------------------------------------------------------------\n"
523 << "Specific workspace variables required by " << mdr.Name() << ":\n"
524 << "---------------------------------------------------------------------\n";
525 for (Index i = 0; i < mdr.In().nelem(); ++i) {
526 cout << "- " << global_data::wsv_data[mdr.In()[i]].Name() << "\n";
527 ++hitcount;
528 }
529 if (0 == hitcount) cout << "none\n";
530
531 cout
532 << "*-------------------------------------------------------------------*\n\n";
533
534 return;
535 }
536
537 // If we are here, then the user specified nothing that makes sense.
538 cerr << "The name " << workspacevariables << " matches neither `all',\n"
539 << "nor the name of a workspace method.\n";
540 arts_exit();
541}
542
549 // Make global data visible:
552
553 // Let's first assume it is a method that the user wants to have
554 // described.
555
556 // Find method id:
557 auto i = MdRawMap.find(describe);
558 if (i != MdRawMap.end()) {
559 // If we are here, then the given name matches a method.
560 cout << md_data_raw[i->second] << "\n";
561 return;
562 }
563
564 // Ok, let's now assume it is a variable that the user wants to have
565 // described.
566
567 // Find wsv id:
569 if (i != global_data::WsvMap.end()) {
570 // If we are here, then the given name matches a workspace
571 // variable.
572 cout << global_data::wsv_data[i->second] << "\n";
573 return;
574 }
575
576 // If we are here, then the given name does not match anything.
577 cerr << "The name " << describe << " matches neither method nor variable.\n";
578 arts_exit();
579}
580
581template <typename TimePoint>
582std::time_t to_time_t(TimePoint time_point) {
583 auto tp = std::chrono::time_point_cast<std::chrono::system_clock::duration>(
584 time_point - TimePoint::clock::now() + std::chrono::system_clock::now());
585 return std::chrono::system_clock::to_time_t(tp);
586}
587
593String arts_mod_time(std::string_view filename) {
594 ostringstream os;
595 try {
596 if (std::filesystem::is_regular_file(filename)) {
597 auto modtime = to_time_t(std::filesystem::last_write_time(filename));
598 os << " (compiled " << std::put_time(std::localtime(&modtime), "%F %T")
599 << ")\n";
600 }
601 } catch (const std::exception&) {
602 // Don't crash if we can't get the modification time.
603 }
604 return os.str();
605}
606
608 std::chrono::high_resolution_clock::time_point arts_realtime_start) {
609 const auto arts_realtime_end = std::chrono::high_resolution_clock::now();
610 return std::chrono::duration<double, std::ratio<1>>(arts_realtime_end -
611 arts_realtime_start)
612 .count();
613}
614
629int main(int argc, char** argv) {
630 extern const Parameters parameters; // Global variable that holds
631 // all command line parameters.
632
633 //---------------< -1. Time the arts run if possible >---------------
634 const auto arts_realtime_start = std::chrono::high_resolution_clock::now();
635
636 //---------------< 1. Get command line parameters >---------------
637 if (get_parameters(argc, argv)) {
638 // Print an error message and exit:
640 }
641
642 //----------< 2. Evaluate the command line parameters >----------
643 if (parameters.help) {
644 // Just print a help message and then exit.
645 cout << "\n" << parameters.usage << "\n\n";
646 cout << parameters.helptext << "\n\n";
647 arts_exit(EXIT_SUCCESS);
648 }
649
650 ostringstream osfeatures;
651 {
652 osfeatures << "Compiler: " << String(COMPILER) << endl;
653
654 if (String(COMPILER) != "Xcode")
655 osfeatures << "Compile flags: " << COMPILE_FLAGS << endl;
656
657 osfeatures << "Features in this build: " << endl
658 << " Numeric precision: "
659 << ((sizeof(Numeric) == sizeof(double)) ? "double" : "float")
660 << endl
661 << " OpenMP support: "
662#ifdef _OPENMP
663 << "enabled" << endl
664#else
665 << "disabled" << endl
666#endif
667 << " Documentation server: "
668#ifdef ENABLE_DOCSERVER
669 << "enabled" << endl
670#else
671 << "disabled" << endl
672#endif
673 << " Zipped XML support: "
674#ifdef ENABLE_ZLIB
675 << "enabled" << endl
676#else
677 << "disabled" << endl
678#endif
679 << " NetCDF support: "
680#ifdef ENABLE_NETCDF
681 << "enabled" << endl
682#else
683 << "disabled" << endl
684#endif
685 << " Fortran support: "
686#ifdef FORTRAN_COMPILER
687 << "enabled (" << FORTRAN_COMPILER << ")" << endl
688#else
689 << "disabled" << endl
690#endif
691 << " Legacy Fortran Disort:"
692#ifdef ENABLE_DISORT
693 << "enabled" << endl
694#else
695 << "disabled" << endl
696#endif
697 << " RT4 support: "
698#ifdef ENABLE_RT4
699 << "enabled" << endl
700#else
701 << "disabled" << endl
702#endif
703 << " FASTEM support: "
704#ifdef ENABLE_FASTEM
705 << "enabled" << endl
706#else
707 << "disabled" << endl
708#endif
709 << " OEM support: "
710#ifdef OEM_SUPPORT
711 << "enabled" << endl
712 << " MPI support for OEM: "
713#ifdef ENABLE_MPI
714 << "enabled" << endl
715#else
716 << "disabled" << endl
717#endif
718#else
719 << "disabled" << endl
720#endif
721 << " Refice support: "
722#ifdef ENABLE_REFICE
723 << "enabled" << endl
724#else
725 << "disabled" << endl
726#endif
727 << " Tmatrix support: "
728#ifdef ENABLE_TMATRIX
729#ifdef ENABLE_TMATRIX_QUAD
730 << "enabled (quad-precision)" << endl
731#else
732 << "enabled (double-precision)" << endl
733#endif
734#else
735 << "disabled" << endl
736#endif
737 << " IPO/LTO support: "
738#ifdef IPO_SUPPORTED
739 << "enabled" << endl
740#else
741 << "disabled" << endl
742#endif
743 << endl;
744
745 osfeatures << "Include search paths: " << endl;
746 for (auto& path : parameters.includepath) {
747 osfeatures << " " << path << endl;
748 }
749
750 osfeatures << "Data searchpaths: " << endl;
751 for (auto& path : parameters.datapath) {
752 osfeatures << " " << path << endl;
753 }
754 }
755
756 if (parameters.version) {
757 cout << arts_get_version_string() << arts_mod_time(argv[0]) << endl;
758 cout << osfeatures.str();
759 arts_exit(EXIT_SUCCESS);
760 }
761
763#ifdef _OPENMP
764 omp_set_num_threads((int)parameters.numthreads);
765#else
766 cerr << "Ignoring commandline option --numthreads/-n.\n"
767 << "This option only works with an OpenMP enabled ARTS build.\n";
768#endif
769 }
770
771 // For the next couple of options we need to have the workspce and
772 // method lookup data.
773
774 // Initialize the wsv group name array:
776
777 // Initialize the wsv data:
779
780 // Initialize WsvMap:
782
783 // Initialize the md data:
785
786 // Expand supergeneric methods:
788
789 // Initialize MdMap:
791
792 // Initialize MdRawMap (needed by parser and online docu).
794
795 // Initialize the agenda lookup data:
797
798 // Initialize AgendaMap:
800
801 // Check that agenda information in wsv_data and agenda_data is consistent:
803
804 // Initialize memory handler.
806
807 auto workspace_shared = Workspace::create();
808
809 Workspace& workspace=*workspace_shared;
810
811 // Make all global data visible:
813
814 // Now we are set to deal with the more interesting command line
815 // switches.
816#ifdef ENABLE_DOCSERVER
818 // Check built-in docs and then exit
819 const auto broken_links = Docserver::list_broken_description_links();
820 const size_t nbroken = std::get<0>(broken_links);
821 for (auto&& s : std::get<1>(broken_links)) {
822 std::cout << s << std::endl;
823 }
824 std::cout << std::endl
825 << nbroken << " broken link" << (nbroken == 1 ? "" :"s")
826 << " found." << std::endl;
827 arts_exit(nbroken ? EXIT_FAILURE : EXIT_SUCCESS);
828 }
829#endif
830
831 // React to option `methods'. If given the argument `all', it
832 // should simply prints a list of all methods. If given the name of
833 // a variable, it should print all methods that produce this
834 // variable as output.
835 if ("" != parameters.methods) {
837 arts_exit(EXIT_SUCCESS);
838 }
839
840 // React to option `input'. Given the name of a variable (or group)
841 // it should print all methods that need this variable (or group) as
842 // input.
843 if ("" != parameters.input) {
845 arts_exit(EXIT_SUCCESS);
846 }
847
848 // React to option `workspacevariables'. If given the argument `all',
849 // it should simply prints a list of all variables. If given the
850 // name of a method, it should print all variables that are needed
851 // by that method.
852 if ("" != parameters.workspacevariables) {
854 arts_exit(EXIT_SUCCESS);
855 }
856
857 // React to option `describe'. This should print the description
858 // String of the given workspace variable or method.
859 if ("" != parameters.describe) {
861 arts_exit(EXIT_SUCCESS);
862 }
863
864 // React to option `groups'. This should simply print a list of all
865 // workspace variable groups.
866 if (parameters.groups) {
867 if (!parameters.plain) {
868 cout
869 << "\n*-------------------------------------------------------------------*\n"
870 << "Complete list of ARTS workspace variable groups:\n"
871 << "---------------------------------------------------------------------\n";
872 }
873
874 for (Index i = 0; i < wsv_groups.nelem(); ++i) {
875 if (!parameters.plain) cout << "- ";
876 cout << wsv_groups[i] << "\n";
877 }
878
879 if (!parameters.plain)
880 cout
881 << "*-------------------------------------------------------------------*\n\n";
882 arts_exit(EXIT_SUCCESS);
883 }
884
885#ifdef ENABLE_DOCSERVER
886 if (0 != parameters.docserver) {
888 arts_exit(0);
889 }
890#endif
891
892 // Ok, we are past all the special options. This means the user
893 // wants to get serious and really do a calculation. Check if we
894 // have at least one control file:
895 if (0 == parameters.controlfiles.nelem()) {
896 cerr << "You must specify at least one control file name.\n";
898 }
899
900 // Set the basename according to the first control file, if not
901 // explicitly specified.
902 if ("" == parameters.basename) {
903 extern String out_basename;
904 ArrayOfString fileparts;
905 parameters.controlfiles[0].split(fileparts, "/");
906 out_basename = fileparts[fileparts.nelem() - 1];
907 // Find the last . in the name
908 String::size_type p = out_basename.rfind(".arts");
909
910 if (String::npos == p) {
911 // This is an error handler for the case that somebody gives
912 // a supposed file name that does not contain the extension
913 // ".arts"
914
915 cerr << "The controlfile must have the extension .arts.\n";
917 }
918
919 // Kill everything starting from the `.'
920 out_basename.erase(p);
921 } else {
922 extern String out_basename;
924 }
925
926 // Set the global reporting level, either from reporting command line
927 // option or default.
929
930 // Keep around a global copy of the verbosity levels at launch, so that
931 // verbosityInit() can be used to reset them in the control file
933 Verbosity verbosity;
934 verbosity = verbosity_at_launch;
935 verbosity.set_main_agenda(true);
936
938
939 //--------------------< Open report file >--------------------
940 // This one needs its own little try block, because we have to
941 // write error messages to cerr directly since the report file
942 // will not exist.
943 try {
944 extern String out_basename; // Basis for file name
945 extern ofstream report_file; // Report file pointer
946 ostringstream report_file_ext;
947
948 report_file_ext << ".rep";
949 open_output_file(report_file, out_basename + report_file_ext.str());
950 } catch (const std::runtime_error& x) {
951 cerr << x.what() << "\n"
952 << "I have to be able to write to my report file.\n";
953 arts_exit();
954 }
955
956 // Now comes the global try block. Exceptions caught after this
957 // one are general stuff like file opening errors.
958 try {
959 out1 << "Executing ARTS.\n";
960
961 // Output command line:
962 out1 << "Command line:\n";
963 for (Index i = 0; i < argc; ++i) {
964 out1 << argv[i] << " ";
965 }
966 out1 << "\n";
967
968 // Output full program name (with version number):
969 out1 << "Version: " << arts_get_version_string() << arts_mod_time(argv[0])
970 << "\n";
971
972 // Output more details about the compilation:
973 out2 << osfeatures.str() << "\n";
974
975 // Output some OpenMP specific information on output level 2:
976#ifdef _OPENMP
977 out2 << "Running with OpenMP, "
978 << "maximum number of threads = " << arts_omp_get_max_threads()
979 << ".\n";
980#else
981 out2 << "Running without OpenMP.\n";
982#endif
983
984 // Output a short hello from each thread to out3:
985#ifdef _OPENMP
986#pragma omp parallel default(none) shared(out3)
987 {
988 ostringstream os;
989 int tn = arts_omp_get_thread_num();
990 os << " Thread " << tn << ": ready.\n";
991 out3 << os.str();
992 }
993#endif
994 out2 << "\n";
995
996 time_t rawtime;
997 struct tm* timeinfo;
998
999 time(&rawtime);
1000 timeinfo = localtime(&rawtime);
1001 out2 << "Run started: " << asctime(timeinfo) << "\n";
1002
1003 // Output verbosity settings. This is not too interesting, it
1004 // goes only to out3.
1005 out3 << "Verbosity settings: Agendas: "
1006 << verbosity.get_agenda_verbosity() << "\n"
1007 << " Screen: "
1008 << verbosity.get_screen_verbosity() << "\n"
1009 << " Report file: "
1010 << verbosity.get_file_verbosity() << "\n";
1011
1012 out3 << "\nReading control files:\n";
1013 for (Index i = 0; i < parameters.controlfiles.nelem(); ++i) {
1014 try {
1015 out3 << "- " << parameters.controlfiles[i] << "\n";
1016
1017 // The list of methods to execute and their keyword data from
1018 // the control file.
1019 Agenda tasklist{workspace};
1020
1021 // Call the parser to parse the control text:
1022 ArtsParser arts_parser(tasklist, parameters.controlfiles[i], verbosity);
1023
1024 arts_parser.parse_tasklist();
1025
1026 tasklist.set_name("Arts");
1027
1028 tasklist.set_main_agenda();
1029
1030 // Execute main agenda:
1031 Arts2(workspace, tasklist, verbosity);
1032 } catch (const std::exception& x) {
1033 ostringstream os;
1034 os << "Run-time error in controlfile: " << parameters.controlfiles[i]
1035 << '\n'
1036 << x.what();
1037 throw runtime_error(os.str());
1038 }
1039 }
1040 } catch (const std::runtime_error& x) {
1041 out1 << "This run took " << fixed << setprecision(2)
1042 << get_arts_runtime_in_sec(arts_realtime_start) << "s\n";
1043
1044 arts_exit_with_error_message(x.what(), out0);
1045 }
1046
1047 out1 << "This run took " << fixed << setprecision(2)
1048 << get_arts_runtime_in_sec(arts_realtime_start) << "s\n";
1049
1050 out1 << "Everything seems fine. Goodbye.\n";
1051 arts_exit(EXIT_SUCCESS);
1052}
Declarations required for the calculation of absorption coefficients.
void define_agenda_map()
bool check_agenda_data()
Check that agendas.cc and workspace.cc are consistent.
Declarations for AgRecord, storing lookup information for one agenda.
void define_agenda_data()
Definition: agendas.cc:44
void arts_exit_with_error_message(const String &m, ArtsOut &out)
Print error message and exit.
Definition: arts.cc:64
void arts_exit(int status)
This is the exit function of ARTS.
Definition: arts.cc:42
The global header file for ARTS.
void define_wsv_groups()
Define the array of workspace variable group names.
Definition: groups.cc:66
std::string_view arts_get_version_string()
Definition: auto_version.cc:4
int arts_omp_get_max_threads()
Wrapper for omp_get_max_threads.
Definition: arts_omp.cc:46
int arts_omp_get_thread_num()
Wrapper for omp_get_thread_num.
Definition: arts_omp.cc:76
Header file for helper functions for OpenMP.
The Agenda class.
Definition: agenda_class.h:69
Index nelem() const ARTS_NOEXCEPT
Definition: array.h:92
void parse_tasklist()
Public interface to the main function of the parser.
Definition: parser.cc:54
All information for one workspace method.
Definition: methods.h:38
const ArrayOfIndex & In() const
Definition: methods.h:93
const String & Name() const
Definition: methods.h:85
const ArrayOfIndex & GOutType() const
Definition: methods.h:90
const ArrayOfArrayOfIndex & GInSpecType() const
Definition: methods.h:96
const ArrayOfArrayOfIndex & GOutSpecType() const
Definition: methods.h:91
const ArrayOfIndex & Out() const
Definition: methods.h:88
const ArrayOfIndex & GInType() const
Definition: methods.h:95
Structure to hold all command line Parameters.
Definition: parameters.h:42
bool check_docs
Flag to check built-in documentation.
Definition: parameters.h:133
ArrayOfString includepath
List of paths to search for include files.
Definition: parameters.h:106
String helptext
Longer message explaining the options.
Definition: parameters.h:74
String usage
Short message how to call the program.
Definition: parameters.h:72
bool version
Display version information.
Definition: parameters.h:78
ArrayOfString datapath
List of paths to search for data files.
Definition: parameters.h:108
String workspacevariables
If this is given the argument ‘all’, it simply prints a list of all workspace variables.
Definition: parameters.h:116
String baseurl
Baseurl for the docserver.
Definition: parameters.h:127
String input
This is complementary to the methods switch.
Definition: parameters.h:112
ArrayOfString controlfiles
The filenames of the controlfiles.
Definition: parameters.h:90
bool plain
Generate plain help out suitable for script processing.
Definition: parameters.h:123
String basename
If this is specified (with the -b –basename option), it is used as the base name for the report file ...
Definition: parameters.h:82
bool groups
Print a list of all workspace variable groups.
Definition: parameters.h:121
bool help
Only display the help text.
Definition: parameters.h:76
Index reporting
This should be a two digit integer.
Definition: parameters.h:98
Index numthreads
The maximum number of threads to use.
Definition: parameters.h:104
Index docserver
Port to use for the docserver.
Definition: parameters.h:125
bool daemon
Flag to run the docserver in the background.
Definition: parameters.h:129
String describe
Print the description String of the given workspace variable or method.
Definition: parameters.h:119
String methods
If this is given the argument ‘all’, it simply prints a list of all methods.
Definition: parameters.h:102
Index get_screen_verbosity() const
Definition: messages.h:65
void set_main_agenda(bool main_agenda)
Definition: messages.h:72
Index get_agenda_verbosity() const
Definition: messages.h:64
void set_screen_verbosity(Index v)
Definition: messages.h:70
bool valid() const
Check if artsmessages contains valid message levels.
Definition: messages.h:60
void set_agenda_verbosity(Index v)
Definition: messages.h:69
Index get_file_verbosity() const
Definition: messages.h:66
void set_file_verbosity(Index v)
Definition: messages.h:71
void initialize()
Initialization dispatch functions.
Workspace class.
Definition: workspace_ng.h:53
std::shared_ptr< wsv_data_type > wsv_data_ptr
Definition: workspace_ng.h:76
static std::shared_ptr< Workspace > create()
Creates a new Workspace, it has to be created as a shared pointer.
std::shared_ptr< WsvMap_type > WsvMap_ptr
Definition: workspace_ng.h:79
static const Index npos
Define npos:
Definition: mystring.h:209
#define COMPILE_FLAGS
Definition: config.h:4
#define COMPILER
Definition: config.h:7
#define FORTRAN_COMPILER
Definition: config.h:10
#define ARTS_ASSERT(condition,...)
Definition: debug.h:82
String describe(ConstTensor7View x)
Describe Tensor7.
Definition: describe.cc:38
Declarations for the arts documentation server.
The declarations of all the exception classes.
void open_output_file(ofstream &file, const std::string_view name)
Open a file for writing.
Definition: file.cc:80
This file contains basic functions to handle ASCII files.
Index get_wsv_group_id(const String &name)
Returns the id of the given group.
Definition: groups.cc:360
int main()
void Arts2(Workspace &ws, const Agenda &input_agenda, const Verbosity &verbosity)
WORKSPACE METHOD: Arts2.
Definition: m_agenda.cc:210
void set_reporting_level(Index r)
Set the reporting level.
Definition: main.cc:81
void option_workspacevariables(const String &workspacevariables)
React to option ‘workspacevariables’.
Definition: main.cc:466
std::time_t to_time_t(TimePoint time_point)
Definition: main.cc:582
void option_methods(Workspace &workspace, const String &methods)
React to option ‘methods’.
Definition: main.cc:123
double get_arts_runtime_in_sec(std::chrono::high_resolution_clock::time_point arts_realtime_start)
Definition: main.cc:607
void option_input(const String &input)
React to option ‘input’.
Definition: main.cc:305
String arts_mod_time(std::string_view filename)
This function returns the modification time of the arts executable as a string.
Definition: main.cc:593
void polite_goodby()
Remind the user of –help and exit return value 1.
Definition: main.cc:63
void option_describe(const String &describe)
React to option ‘describe’.
Definition: main.cc:548
NUMERIC Numeric
The type to use for all floating point numbers.
Definition: matpack.h:33
INDEX Index
The type to use for all integer numbers and indices.
Definition: matpack.h:39
Verbosity verbosity_at_launch
The global message verbosity settings:
Definition: messages.cc:34
String out_basename
The basename for the report file and for all other output files.
Definition: messages.cc:42
ofstream report_file
The report file.
Definition: messages.cc:45
Declarations having to do with the four output streams.
#define CREATE_OUTS
Definition: messages.h:208
void define_md_data_raw()
Definition: methods.cc:190
Declaration of the class MdRecord.
void define_md_raw_map()
Define MdRawMap.
Definition: methods_aux.cc:511
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
This file contains the definition of String, the ARTS string class.
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
WorkspaceMemoryHandler workspace_memory_handler
The workspace memory handler Defined in workspace_ng.cc.
Definition: workspace_ng.cc:37
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
bool get_parameters(int argc, char **argv)
Get the command line parameters.
Definition: parameters.cc:71
Parameters parameters
Holds the command line parameters.
Definition: parameters.cc:41
This file contains header information for the dealing with command line parameters.
void define_wsv_data()
Definition: workspace.cc:48
void define_wsv_map()
Definition: workspace.cc:5711
This file contains the Workspace class.
Auxiliary header stuff related to workspace variable groups.