ARTS  2.0.49
arts.cc
Go to the documentation of this file.
1 /* Copyright (C) 2003-2008 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 
27 #include <cstdlib>
28 #include <stdexcept>
29 #include "arts.h"
30 #include "file.h"
31 #include "messages.h"
32 
33 
42 void arts_exit(int status)
43 {
44  extern ofstream report_file;
45  extern String out_basename; // Basis for file name
46  ostringstream report_file_ext;
47 
48  report_file_ext << ".rep";
49  cleanup_output_file(report_file, out_basename + report_file_ext.str());
50 
51  exit (status);
52 }
53 
55 
65 {
66  {
67  ostringstream os;
68  os << m << "\n"
69  << "Stopping ARTS execution.\n"
70  << "Goodbye.\n";
71  out << os.str();
72 
73  arts_exit(); // No argument means failure.
74  }
75 }
76 
78 
89 #ifdef _OPENMP
90 void exit_or_rethrow(const String& m, ArtsOut &out)
91 {
92  // With OpenMP, we have to terminate the program,
93  // because exceptions can not be thrown out of the
94  // parallel region.
96 }
97 #else
98 void exit_or_rethrow(const String& m, ArtsOut &out _U_)
99 {
100  // Without OpenMP, we can re-throw the exception, to
101  // be handled higher up. This to preserve the
102  // "robust" option in ybatchCalc.
103  throw runtime_error(m);
104 }
105 #endif
106 
cleanup_output_file
void cleanup_output_file(ofstream &, const String &)
Closes the file.
Definition: file.cc:146
exit_or_rethrow
void exit_or_rethrow(const String &m, ArtsOut &out)
Exit ARTS or re-throw error.
Definition: arts.cc:98
ArtsOut
Definition: messages.h:86
messages.h
Declarations having to do with the four output streams.
_U_
#define _U_
Definition: config.h:158
my_basic_string
The implementation for String, the ARTS string class.
Definition: mystring.h:62
report_file
ofstream report_file
The report file.
Definition: messages.cc:45
out_basename
String out_basename
The basename for the report file and for all other output files.
Definition: messages.cc:42
file.h
This file contains basic functions to handle ASCII files.
arts_exit
void arts_exit(int status)
This is the exit function of ARTS.
Definition: arts.cc:42
arts_exit_with_error_message
void arts_exit_with_error_message(const String &m, ArtsOut &out)
Print error message and exit.
Definition: arts.cc:64
arts.h
The global header file for ARTS.