OPAL (Object Oriented Parallel Accelerator Library) 2022.1
OPAL
Globals.cpp
Go to the documentation of this file.
1#include <gsl/gsl_errno.h>
3
4// Note the gymnastics here - we only want to define gmsg and ippl once
5#define PYOPAL_GLOBALS_C
7
8namespace {
9 void errorHandlerGSL(const char *reason,
10 const char *file,
11 int line,
12 int gsl_errno) {
13 throw OpalException(file, reason);
14 if (line || gsl_errno) {;} // disable gcc warning; does nothing
15 }
16}
17
18namespace PyOpal {
19namespace Globals {
20void Initialise() {
21 if (gmsg == nullptr) {
22 gmsg = new Inform("OPAL");
23 }
24 if (ippl == nullptr) {
25 int argc = 3;
26 // I am not strong on the C-style strings, but if I understand correctly
27 // there is a secret null pointer at the end of each string, hence the
28 // char arrays have to be one character longer than you might think.
29 char* argvr[4];
30 argvr[0] = new char[7];
31 strcpy(argvr[0], "pyopal");
32 argvr[1] = new char[12];
33 strcpy(argvr[1], "--processes");
34 argvr[2] = new char[2];
35 strcpy(argvr[2], "3");
36 argvr[3] = nullptr;
37 char** argv = argvr;
38 // Ippl is a typedef of IpplInfo in ippl/Utilities
39 ippl = new Ippl(argc, argv);
40 }
41 gsl_set_error_handler(&errorHandlerGSL);
42}
43}
44}
IpplInfo Ippl
Definition: IpplInfo.h:353
void Initialise()
Definition: Globals.cpp:78
The base class for all OPAL exceptions.
Definition: OpalException.h:28
Definition: Inform.h:42
Ippl * ippl
Definition: Main.cpp:60
Inform * gmsg
Definition: Main.cpp:61