00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00041
00042
00043
00044
00045 #include <stdexcept>
00046
00047 #include "arts.h"
00048
00049 #include "m_general.h"
00050 #include "array.h"
00051 #include "check_input.h"
00052 #include "messages.h"
00053 #include "mystring.h"
00054
00055 #include "math_funcs.h"
00056 #include "make_vector.h"
00057 #include "wsv_aux.h"
00058
00059 #include "workspace_ng.h"
00060
00061
00062
00063
00064
00065
00066 void INCLUDE()
00067 {
00068 }
00069
00070
00071
00072 void Print(
00073 Workspace& ws _U_,
00074
00075 const Agenda& x,
00076
00077 const Index& level )
00078 {
00079 ostringstream os;
00080 os << " " << x << "\n";
00081 SWITCH_OUTPUT (level, os.str ())
00082 }
00083
00084
00085
00086 void Print(
00087
00088 const ArrayOfGridPos& x,
00089
00090 const Index& level )
00091 {
00092 ostringstream os;
00093 for( Index i=0; i<x.nelem(); i++ )
00094 os << " " << x[i].idx << " " << x[i].fd[0] << " " << x[i].fd[1]
00095 << "\n";
00096 SWITCH_OUTPUT (level, os.str ())
00097 }
00098
00099
00100
00101 void Print(
00102
00103 const ArrayOfIndex& x,
00104
00105 const Index& level )
00106 {
00107 ostringstream os;
00108 for( Index i=0; i<x.nelem(); i++ )
00109 os << x[i];
00110 SWITCH_OUTPUT (level, os.str () << '\n')
00111 }
00112
00113
00114
00115 void Print(
00116
00117 const ArrayOfString& x,
00118
00119 const Index& level )
00120 {
00121 ostringstream os;
00122 for( Index i=0; i<x.nelem(); i++ )
00123 os << x[i] << '\n';
00124 SWITCH_OUTPUT (level, os.str ())
00125 }
00126
00127
00128
00129 void
00130 Print(
00131
00132 const Ppath& x,
00133
00134 const Index& level )
00135 {
00136 SWITCH_OUTPUT (level, "dim: ")
00137 Print( x.dim, level );
00138 SWITCH_OUTPUT (level, "np: ")
00139 Print( x.np, level );
00140 SWITCH_OUTPUT (level, "refraction: ")
00141 Print( x.refraction, level );
00142 SWITCH_OUTPUT (level, "method: ")
00143 Print( x.method, level );
00144 SWITCH_OUTPUT (level, "constant: ")
00145 Print( x.constant, level );
00146 SWITCH_OUTPUT (level, "pos: ")
00147 Print( x.pos, level );
00148 SWITCH_OUTPUT (level, "z: ")
00149 Print( x.z, level );
00150 SWITCH_OUTPUT (level, "l_step: ")
00151 Print( x.l_step, level );
00152 SWITCH_OUTPUT (level, "gp_p: ")
00153 Print( x.gp_p, level );
00154 if( x.dim >= 2 )
00155 {
00156 SWITCH_OUTPUT (level, "gp_lat: ")
00157 Print( x.gp_lat, level );
00158 }
00159 if( x.dim == 3 )
00160 {
00161 SWITCH_OUTPUT (level, "gp_lon: ")
00162 Print( x.gp_lon, level );
00163 }
00164 SWITCH_OUTPUT (level, "los: ")
00165 Print( x.los, level );
00166 SWITCH_OUTPUT (level, "background: ")
00167 Print( x.background, level );
00168 if( x.tan_pos.nelem() )
00169 {
00170 SWITCH_OUTPUT (level, "tan_pos: ")
00171 Print( x.tan_pos, level );
00172 }
00173 if( x.geom_tan_pos.nelem() )
00174 {
00175 SWITCH_OUTPUT (level, "geom_tan_pos: ")
00176 Print( x.geom_tan_pos, level );
00177 }
00178 }
00179
00180
00181
00182 void Print(
00183
00184 const ArrayOfPpath& x,
00185
00186 const Index& level )
00187 {
00188 for( Index i=0; i<x.nelem(); i++ )
00189 {
00190 ostringstream os;
00191 os << "Ppath element " << i << ": ";
00192 SWITCH_OUTPUT (level, os.str ())
00193 Print( x[i], level );
00194 }
00195 }
00196
00197
00198
00199 void Print(
00200
00201 const Timer& ,
00202
00203 const Index& )
00204 {
00205
00206
00207
00208
00209
00210
00211 }
00212
00213
00214
00215 void PrintWorkspace(
00216
00217 Workspace& ws,
00218
00219 const Index& only_allocated,
00220 const Index& level)
00221 {
00222 ostringstream os;
00223
00224 if (only_allocated)
00225 os << " Allocated workspace variables: \n";
00226 else
00227 os << " Workspace variables: \n";
00228 for (Index i = 0; i < ws.nelem(); i++)
00229 {
00230 if (!only_allocated)
00231 {
00232 os << " ";
00233 PrintWsvName (os, i);
00234 if (ws.is_initialized(i)) os << "+";
00235 os << "\n";
00236 }
00237 else if (ws.is_initialized(i))
00238 {
00239 os << " ";
00240 PrintWsvName (os, i);
00241 os << "\n";
00242 }
00243 }
00244 SWITCH_OUTPUT (level, os.str ());
00245 }
00246
00247
00248
00249 #ifdef _POSIX_VERSION
00250 void
00251 timerStart (
00252 Timer& starttime)
00253 {
00254 if ((starttime.realtime = times (&starttime.cputime)) == (clock_t)-1)
00255 throw runtime_error ("Timer error: Unable to get current CPU time");
00256 }
00257 #else
00258 void
00259 timerStart (
00260 Timer& )
00261 {
00262 throw runtime_error ("Timer error: ARTS was compiled without POSIX support, thus timer\nfunctions are not available.");
00263 }
00264 #endif
00265
00266
00267
00268 #ifdef _POSIX_VERSION
00269 void
00270 timerStop (
00271 const Timer& starttime)
00272 {
00273 Timer endtime;
00274 static long clktck = 0;
00275
00276 if (clktck == 0)
00277 if ((clktck = sysconf (_SC_CLK_TCK)) < 0)
00278 throw runtime_error ("Timer error: Unable to determine CPU clock ticks");
00279
00280 if ((endtime.realtime = times (&endtime.cputime)) == (clock_t)-1)
00281 throw runtime_error ("Timer error: Unable to get current CPU time");
00282
00283
00284 cout.setf (ios::showpoint | ios::fixed);
00285
00286 out1 << " * CPU time total: " << setprecision (2)
00287 << (Numeric)((endtime.cputime.tms_stime - starttime.cputime.tms_stime)
00288 + (endtime.cputime.tms_utime - starttime.cputime.tms_utime))
00289 / (Numeric)clktck;
00290
00291 out1 << " user: " << setprecision (2)
00292 << (Numeric)(endtime.cputime.tms_utime - starttime.cputime.tms_utime)
00293 / (Numeric)clktck;
00294
00295 out1 << " system: " << setprecision (2)
00296 << (Numeric)(endtime.cputime.tms_stime - starttime.cputime.tms_stime)
00297 / (Numeric)clktck;
00298
00299 out1 << "\n real: " << setprecision (2)
00300 << (Numeric)(endtime.realtime - starttime.realtime) / (Numeric)clktck;
00301
00302 out1 << " " << setprecision (2)
00303 << (Numeric)((endtime.cputime.tms_stime - starttime.cputime.tms_stime)
00304 + (endtime.cputime.tms_utime - starttime.cputime.tms_utime))
00305 / (Numeric)(endtime.realtime - starttime.realtime) * 100.
00306 << "%CPU\n";
00307 }
00308 #else
00309 void
00310 timerStop (
00311 const Timer& starttime)
00312 {
00313 throw runtime_error ("Timer error: ARTS was compiled without POSIX support, thus timer\nfunctions are not available.");
00314 }
00315 #endif
00316
00317
00318 void Error(
00319 const String& msg )
00320 {
00321 out0 << msg << "\n";
00322 arts_exit();
00323 }
00324
00325
00326
00327 void Exit()
00328 {
00329 out1 << " Forced exit.\n";
00330 arts_exit (EXIT_SUCCESS);
00331 }
00332
00333
00334
00335 void Test( )
00336 {
00337
00338
00339 }
00340
00341
00342