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

Contents of /trunk-mpi-branch/pythonMPI/src/ScriptMPI.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1016 - (show annotations)
Thu Mar 8 06:31:28 2007 UTC (12 years, 5 months ago) by gross
File size: 1323 byte(s)
MPI version compiles and starts to run now. 
Important:

   * the mpi library needs to be shared.
   * the path needs to be added to LD_LIBRARY path.

The program stucks in the matrix assemblage.


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

  ViewVC Help
Powered by ViewVC 1.1.26