/[escript]/trunk/pythonMPI/src/ScriptMPI.cpp
ViewVC logotype

Contents of /trunk/pythonMPI/src/ScriptMPI.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 759 - (show annotations)
Thu Jun 29 01:53:23 2006 UTC (16 years, 8 months ago) by bcumming
File size: 1347 byte(s)
- added directory pythonMPI to the source tree. this directory contains
  the c++ wrapper that is used to run python scripts in parallel for the
  MPI version of escript/finley
- updated the SConstruct and ./scons/ess_options.py for conditional MPI
  compilation. To compile the MPI version on ESS uncomment the #define
  PASO_MPI in ./paso/src/Paso.h and add the command line option
  useMPI=yes when running scons.
- fixed a compile time error in the MPI build in  
  finley/src/CPPAdapter/MeshAdapterFactory.cpp 
     

1 #include <Python.h>
2 #include <mpi.h>
3 #include <iostream>
4 #include <stdexcept>
5
6 extern "C"{
7 #include "paso/Paso.h"
8 #include "finley/Finley.h"
9 }
10 #ifdef PASO_MPI
11
12 int main( int argc, char **argv ) {
13 int status = 0;
14 Paso_MPIInfo *mpi_info=NULL;
15 try
16 {
17 /*
18 * Initialise MPI
19 */
20 status = MPI_Init(&argc, &argv);
21 if (status != MPI_SUCCESS) {
22 std::cerr << argv[0] << ": MPI_Init failed, exiting." << std::endl;
23 return status;
24 }
25 mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );
26
27 if( mpi_info->rank )
28 {
29 char fname[256];
30
31 sprintf( fname, "log_P%d.txt", mpi_info->rank );
32 FILE *fp = freopen( fname, "w+", stdout );
33 }
34 /*
35 * Start the python parser
36 */
37 status = Py_Main(argc, argv);
38
39 /*
40 * Finalise MPI for a clean exit.
41 */
42 MPI_Finalize();
43
44 Paso_MPIInfo_dealloc( mpi_info );
45 }
46 catch (std::runtime_error &e)
47 {
48 std::cerr << "EXCEPTION: " << e.what() << std::endl;
49 throw;
50 }
51 catch (char *e)
52 {
53 std::cerr << "EXCEPTION: " << e << std::endl;
54 throw;
55 }
56 catch (...)
57 {
58 std::cerr << "EXCEPTION: " << "UNKNOWN." << std::endl;
59 throw;
60 }
61
62 return status;
63 }
64
65 #else
66 int main( int argc, char **argv ) {
67 printf( "Esys must be compiled with PASO_MPI defined to make the MPI version available\n\n" );
68 return 0;
69 }
70 #endif

  ViewVC Help
Powered by ViewVC 1.1.26