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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1014 - (hide annotations)
Wed Mar 7 09:55:41 2007 UTC (12 years, 6 months ago) by gross
File size: 1324 byte(s)
compiles with mpi now and runs on one processor.
1 bcumming 759 #include <Python.h>
2     #include <mpi.h>
3     #include <iostream>
4     #include <stdexcept>
5    
6     extern "C"{
7 gross 1014 #include "paso/Paso_MPI.h"
8 bcumming 759 }
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    
30     sprintf( fname, "log_P%d.txt", mpi_info->rank );
31     FILE *fp = freopen( fname, "w+", stdout );
32     }
33     /*
34     * Start the python parser
35     */
36     status = Py_Main(argc, argv);
37    
38     /*
39     * Finalise MPI for a clean exit.
40     */
41     MPI_Finalize();
42    
43     Paso_MPIInfo_dealloc( mpi_info );
44     }
45     catch (std::runtime_error &e)
46     {
47     std::cerr << "EXCEPTION: " << e.what() << std::endl;
48     throw;
49     }
50     catch (char *e)
51     {
52     std::cerr << "EXCEPTION: " << e << std::endl;
53     throw;
54     }
55     catch (...)
56     {
57     std::cerr << "EXCEPTION: " << "UNKNOWN." << std::endl;
58     throw;
59     }
60    
61     return status;
62     }
63    
64     #else
65     int main( int argc, char **argv ) {
66     printf( "Esys must be compiled with PASO_MPI defined to make the MPI version available\n\n" );
67     return 0;
68     }
69     #endif

  ViewVC Help
Powered by ViewVC 1.1.26