I have written an mpi app in c that sorts n positive random integers. I would like to put a graphical front end on it and wonder if there is a way to use Python's graphics library via SWIG to do this. I suppose I could resort to TCP or UDP sockets. I have no experience with SWIG or sockets but have a sense that sockets are fairly complex and do know Python.
I'd appreciate some help in going down this path, in terms of code examples and/or learning materials or just some written comments from readers of this list.
Thanks, Scott
Your question is extremely ambiguous, but I'm assuming you have a C program and you want to do some plotting using a Python library.
It looks like you just need to embed the Python interpreter. There is an official guide on embedding.
It's pretty straight forward:
#include <Python.h>
int
main(int argc, char *argv[])
{
Py_SetProgramName(argv[0]); /* optional but recommended */
Py_Initialize();
PyRun_SimpleString("from time import time,ctime\n"
"print 'Today is',ctime(time())\n");
Py_Finalize();
return 0;
}
Just enter your plotting script there. MPI makes no difference.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.