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
113
114
115
116
117
118
119
/* ----------------------------------------------------------------------
LAMMPS - Large-scale Atomic/Molecular Massively Parallel Simulator
http://lammps.sandia.gov, Sandia National Laboratories
Steve Plimpton, sjplimp@sandia.gov
Copyright (2003) Sandia Corporation. Under the terms of Contract
DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains
certain rights in this software. This software is distributed under
the GNU General Public License.
See the README file in the top-level LAMMPS directory.
------------------------------------------------------------------------- */
#include "lmppython.h"
#if LMP_PYTHON
#include "python_impl.h"
#else
#include "error.h"
#endif
using namespace LAMMPS_NS;
/* ---------------------------------------------------------------------- */
Python::Python(LAMMPS *lmp) : Pointers(lmp)
{
// implementation of Python interface is only loaded on demand
// and only if PYTHON package has been installed and compiled into binary
impl = NULL;
}
/* ---------------------------------------------------------------------- */
Python::~Python()
{
delete impl;
}
/* ---------------------------------------------------------------------- */
PythonInterface::~PythonInterface()
{
}
/* ---------------------------------------------------------------------- */
void Python::init()
{
#if LMP_PYTHON
if (!impl) impl = new PythonImpl(lmp);
#else
error->all(FLERR,"Python support missing! Compile with PYTHON package installed!");
#endif
}
/* ---------------------------------------------------------------------- */
bool Python::is_enabled() const {
#if LMP_PYTHON
return true;
#else
return false;
#endif
}
/* ---------------------------------------------------------------------- */
void Python::command(int narg, char **arg)
{
init();
impl->command(narg, arg);
}
/* ------------------------------------------------------------------ */
void Python::invoke_function(int ifunc, char *result)
{
init();
impl->invoke_function(ifunc, result);
}
/* ------------------------------------------------------------------ */
int Python::find(char *name)
{
init();
return impl->find(name);
}
/* ------------------------------------------------------------------ */
int Python::variable_match(char *name, char *varname, int numeric)
{
init();
return impl->variable_match(name, varname, numeric);
}
/* ------------------------------------------------------------------ */
char * Python::long_string(int ifunc)
{
init();
return impl->long_string(ifunc);
}
/* ------------------------------------------------------------------ */
int Python::execute_string(char *cmd)
{
init();
return impl->execute_string(cmd);
}
/* ------------------------------------------------------------------ */
int Python::execute_file(char *fname)
{
init();
return impl->execute_file(fname);
}