File: announce.cc

package info (click to toggle)
healpix-cxx 3.50.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 3,008 kB
  • sloc: cpp: 13,882; ansic: 5,930; sh: 4,451; makefile: 216
file content (112 lines) | stat: -rw-r--r-- 3,146 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
 *  This file is part of libcxxsupport.
 *
 *  libcxxsupport is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  libcxxsupport is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with libcxxsupport; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */

/*
 *  libcxxsupport is being developed at the Max-Planck-Institut fuer Astrophysik
 *  and financially supported by the Deutsches Zentrum fuer Luft- und Raumfahrt
 *  (DLR).
 */

/*
 *  This file contains the implementation of various convenience functions
 *  used by the Planck LevelS package.
 *
 *  Copyright (C) 2002-2011 Max-Planck-Society
 *  Authors: Martin Reinecke, Reinhard Hell
 */

// if we are using g++, check for version 4.0 or higher
#ifdef __GNUC__
#if (__GNUC__<4)
#error your C++ compiler is too old. g++ version 4.0 or higher is required.
#endif
#endif

#include <iostream>
#include "announce.h"
#include "openmp_support.h"

using namespace std;

namespace {

void openmp_status()
  {
#ifndef _OPENMP
  cout << "OpenMP: not supported by this binary" << endl;
#else
  int threads = openmp_max_threads();
  if (threads>1)
    cout << "OpenMP active: max. " << threads << " threads." << endl;
  else
    cout << "OpenMP active, but running with 1 thread only." << endl;
#endif
  }

extern "C" {
int sharp_veclen(void);
}
void vec_status()
  {
  cout << "Supported vector length: " << sharp_veclen() << endl;
  }

} //unnamed namespace

void announce (const string &name)
  {
#ifndef VERSION
#define VERSION "3.50"
#endif
  string version = "v" VERSION;
  string name2 = name+" "+version;
  cout << endl << "+-";
  for (tsize m=0; m<name2.length(); ++m) cout << "-";
  cout << "-+" << endl;
  cout << "| " << name2 << " |" << endl;
  cout << "+-";
  for (tsize m=0; m<name2.length(); ++m) cout << "-";
  cout << "-+" << endl << endl;
  vec_status();
  openmp_status();
  cout << endl;
  }

void module_startup (const string &name, bool argc_valid, const string &usage,
  bool verbose)
  {
  if (verbose) announce (name);
  if (argc_valid) return;
  if (verbose) cerr << usage << endl;
  planck_fail_quietly ("Incorrect usage");
  }

void module_startup (const string &name, int argc, const char **,
  int argc_expected, const string &argv_expected, bool verbose)
  {
  module_startup (name,argc==argc_expected,
    string("Usage: ")+name+" "+argv_expected, verbose);
  }

void module_startup (const std::string &name, int argc, const char ** /*argv*/,
  bool verbose)
  {
  module_startup (name,argc>=2,
    string("Usage:\n  ")+name+" <parameter file / init object>\nor:\n  "
                        +name+" par1=val1 par2=val2 ...", verbose);
  }