-
Notifications
You must be signed in to change notification settings - Fork 5
CAST and Python
It is possible to call python2.7 scripts from CAST via the Python/C API (https://docs.python.org/2/c-api/). For an example how to do this see the DFTB interface (energy_int_dftb.cc) or the FEP analysis tool (in md.cc, function fepanalyze). Set everything that needs python in an environment defined by the USE_PYTHON flag so CAST still can be compiled without python. Py_Initialize() and Py_Finalize() are already called in the beginning and the end of the main.cc file respectively so you don't have to call these functions when adding new python code.
However on our cluster you do not always get such an error message when something in python doesn't work but sometimes CAST just breaks with the message "Segmentation fault". Then go to any node (by "ssh nodeXX"), call python and try the critical python commands manually. Then you should hopefully get an error message that helps you fix the error.
One possibility how this may happen is if you want to plot something with matplotlib.pyplot. Then the error can be fixed by doing
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plotinstead of just
import matplotlib.pyplot as plotat the beginning of you python script.