With user-source the path to (or the name of) a module containing user-provided routines is specified. The module must be importable into Python, i.e., it must either be a Python script (file extension .py), a compiled Python script (file extension .pyc) or a shared library (file extension .so). If the module is already in the systems $PYTHONPATH, the name of the module is sufficient.
The module must provide all user-defined routines required
within the calling program.
In many cases, those routines are written in Fortran or some other
languages, probably not even by the user himself, but are provided by a
third party. If the routine is written in Fortran we suggest using the f2py
Fortran to Python interface generator available at the SciPy homepage.
Another possibility could be writing a wrapper routine which can be
imported into Python. A further possibility is also to start a
background process (e.g. using the Python built-in subprocess
module)
and communicating with it through named pipes.
Simple example of a user-provided source file (Python):
#!/usr/bin/env python # # my_pes.py import numpy def potential(Q): """ My PES routine: harmonic oscillator. Q is a numpy array containing a coordinate vector. """ return numpy.dot(Q,Q)/2