OPAL (Object Oriented Parallel Accelerator Library)
2022.1
OPAL
src
src
PyOpal
PyCore
Globals.cpp
Go to the documentation of this file.
1
#include <gsl/gsl_errno.h>
2
#include "
Utilities/OpalException.h
"
3
4
// Note the gymnastics here - we only want to define gmsg and ippl once
5
#define PYOPAL_GLOBALS_C
6
#include "
PyOpal/PyCore/Globals.h
"
7
8
namespace
{
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
18
namespace
PyOpal
{
19
namespace
Globals {
20
void
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
}
OpalException.h
Ippl
IpplInfo Ippl
Definition:
IpplInfo.h:353
PyOpal
Definition:
ExceptionTranslation.cpp:5
PyOpal::Globals::Initialise
void Initialise()
Definition:
Globals.cpp:78
OpalException
The base class for all OPAL exceptions.
Definition:
OpalException.h:28
Inform
Definition:
Inform.h:42
Globals.h
ippl
Ippl * ippl
Definition:
Main.cpp:60
gmsg
Inform * gmsg
Definition:
Main.cpp:61
Generated on Thu Oct 20 2022 17:40:11 for OPAL (Object Oriented Parallel Accelerator Library) by
1.9.3