QDP++
qdp_scalarvec_init.cc
Go to the documentation of this file.
1
7
8
9#include "qdp.h"
10
11namespace QDP {
12
13
15static bool isInit = false;
16
18void QDP_initialize(int *argc, char ***argv)
19{
20 if (isInit)
21 QDP_error_exit("QDP already inited");
22
23 Layout::init(); // setup extremely basic functionality in Layout
24
25 isInit = true;
26
27 // initialize the global streams
28 QDPIO::cin.init(&std::cin);
29 QDPIO::cout.init(&std::cout);
30 QDPIO::cerr.init(&std::cerr);
31
32 //
33 // Process command line
34 //
35
36 // Look for help
37 bool help_flag = false;
38 for (int i=0; i<*argc; i++)
39 {
40 if (strcmp((*argv)[i], "-h")==0)
41 help_flag = true;
42 }
43
44 if (help_flag)
45 {
46 fprintf(stderr,"Usage: %s options\n",(*argv)[0]);
47 fprintf(stderr,"options:\n");
48 fprintf(stderr," -h help\n");
49#if defined(QDP_USE_PROFILING)
50 fprintf(stderr," -p %%d [%d] profile level\n",
52#endif
53
54 exit(1);
55 }
56
57 for (int i=1; i<*argc; i++)
58 {
59#if defined(QDP_USE_PROFILING)
60 if (strcmp((*argv)[i], "-p")==0)
61 {
62 int lev;
63 sscanf((*argv)[++i], "%d", &lev);
65 }
66#endif
67
68 if (i >= *argc)
69 {
70 QDP_error_exit("missing argument at the end");
71 }
72 }
73
74 initProfile(__FILE__, __func__, __LINE__);
75}
76
78bool QDP_isInitialized() {return isInit;}
79
81void QDP_finalize()
82{
84
85 isInit = false;
86}
87
89void QDP_abort(int status)
90{
91 QDP_finalize();
92 exit(status);
93}
94
96void QDP_resume() {}
97
99void QDP_suspend() {}
100
101
102} // namespace QDP;
void init()
Initializer for layout.
StandardOutputStream cout
Definition qdp_stdio.cc:21
StandardOutputStream cerr
Definition qdp_stdio.cc:22
StandardInputStream cin
Definition qdp_stdio.cc:20
Yet another random number generator.
void printProfile()
int getProfileLevel()
bool QDP_isInitialized()
Is the machine initialized?
void QDP_error_exit(const char *format,...)
Simple error display and abort routine.
Definition qdp_util.cc:93
void QDP_initialize(int *argc, char ***argv)
Turn on the machine.
static bool isInit
Private flag for status.
void QDP_suspend()
Suspends QDP communications.
int setProgramProfileLevel(int n)
void QDP_abort(int status)
Panic button.
void QDP_resume()
Resumes QDP communications.
void initProfile(const std::string &file, const std::string &caller, int line)
void QDP_finalize()
Turn off the machine.
Primary include file for QDP.