LevelS C++ support library  3.83
announce.cc
1 /*
2  * This file is part of libcxxsupport.
3  *
4  * libcxxsupport is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * libcxxsupport is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with libcxxsupport; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 /*
20  * libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
21  * and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
22  * (DLR).
23  */
24 
25 /*
26  * This file contains the implementation of various convenience functions
27  * used by the Planck LevelS package.
28  *
29  * Copyright (C) 2002-2011 Max-Planck-Society
30  * Authors: Martin Reinecke, Reinhard Hell
31  */
32 
33 // if we are using g++, check for version 4.0 or higher
34 #ifdef __GNUC__
35 #if (__GNUC__<4)
36 #error your C++ compiler is too old. g++ version 4.0 or higher is required.
37 #endif
38 #endif
39 
40 #include <iostream>
41 #include "announce.h"
42 #include "openmp_support.h"
43 
44 using namespace std;
45 
46 namespace {
47 
48 void openmp_status()
49  {
50 #ifndef _OPENMP
51  cout << "OpenMP: not supported by this binary" << endl;
52 #else
53  int threads = openmp_max_threads();
54  if (threads>1)
55  cout << "OpenMP active: max. " << threads << " threads." << endl;
56  else
57  cout << "OpenMP active, but running with 1 thread only." << endl;
58 #endif
59  }
60 
61 extern "C" {
62 int sharp_veclen(void);
63 }
64 void vec_status()
65  {
66  cout << "Supported vector length: " << sharp_veclen() << endl;
67  }
68 
69 } //unnamed namespace
70 
71 void announce (const string &name)
72  {
73 #ifndef VERSION
74 #define VERSION "3.83"
75 #endif
76  string version = "v" VERSION;
77  string name2 = name+" "+version;
78  cout << endl << "+-";
79  for (tsize m=0; m<name2.length(); ++m) cout << "-";
80  cout << "-+" << endl;
81  cout << "| " << name2 << " |" << endl;
82  cout << "+-";
83  for (tsize m=0; m<name2.length(); ++m) cout << "-";
84  cout << "-+" << endl << endl;
85  vec_status();
86  openmp_status();
87  cout << endl;
88  }
89 
90 void module_startup (const string &name, bool argc_valid, const string &usage,
91  bool verbose)
92  {
93  if (verbose) announce (name);
94  if (argc_valid) return;
95  if (verbose) cerr << usage << endl;
96  planck_fail_quietly ("Incorrect usage");
97  }
98 
99 void module_startup (const string &name, int argc, const char **,
100  int argc_expected, const string &argv_expected, bool verbose)
101  {
102  module_startup (name,argc==argc_expected,
103  string("Usage: ")+name+" "+argv_expected, verbose);
104  }
105 
106 void module_startup (const std::string &name, int argc, const char ** /*argv*/,
107  bool verbose)
108  {
109  module_startup (name,argc>=2,
110  string("Usage:\n ")+name+" <parameter file / init object>\nor:\n "
111  +name+" par1=val1 par2=val2 ...", verbose);
112  }
#define planck_fail_quietly(msg)
std::size_t tsize
Definition: datatypes.h:116
void module_startup(const std::string &name, bool argc_valid, const std::string &usage, bool verbose=true)
void announce(const std::string &name)

Generated on Wed Nov 13 2024 12:18:16 for LevelS C++ support library