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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2083 - (hide annotations)
Fri Nov 21 01:46:31 2008 UTC (10 years, 5 months ago) by caltinay
File size: 2003 byte(s)
Same "fix" as before for unused fp_out and fp_err.

1 ksteube 1312
2     /*******************************************************
3 ksteube 1811 *
4     * Copyright (c) 2003-2008 by University of Queensland
5     * Earth Systems Science Computational Center (ESSCC)
6     * http://www.uq.edu.au/esscc
7     *
8     * Primary Business: Queensland, Australia
9     * Licensed under the Open Software License version 3.0
10     * http://www.opensource.org/licenses/osl-3.0.php
11     *
12     *******************************************************/
13 ksteube 1312
14 ksteube 1811
15 bcumming 759 #include <Python.h>
16 ksteube 1705 #ifdef PASO_MPI
17 bcumming 759 #include <mpi.h>
18 ksteube 1705 #endif
19 bcumming 759 #include <iostream>
20     #include <stdexcept>
21    
22     extern "C"{
23 ksteube 1312 #include "paso/Paso_MPI.h"
24 bcumming 759 }
25     #ifdef PASO_MPI
26    
27     int main( int argc, char **argv ) {
28     int status = 0;
29 gross 1556 int provided;
30 bcumming 759 Paso_MPIInfo *mpi_info=NULL;
31     try
32     {
33     /*
34     * Initialise MPI
35     */
36 gross 1761 /* status = MPI_Init(&argc, &argv); */
37     status = MPI_Init_thread(&argc, &argv, MPI_THREAD_FUNNELED, &provided );
38 bcumming 759 if (status != MPI_SUCCESS) {
39     std::cerr << argv[0] << ": MPI_Init failed, exiting." << std::endl;
40     return status;
41     }
42     mpi_info = Paso_MPIInfo_alloc( MPI_COMM_WORLD );
43    
44     if( mpi_info->rank )
45     {
46     char fname[256];
47 ksteube 1312 sprintf( fname, "stdout_cpu_%04d.out", mpi_info->rank );
48 caltinay 2083 FILE *fp_out;
49     fp_out = freopen( fname, "w+", stdout );
50 ksteube 1312 sprintf( fname, "stdout_cpu_%04d.err", mpi_info->rank );
51 caltinay 2083 FILE *fp_err;
52     fp_err = freopen( fname, "w+", stderr );
53 bcumming 759 }
54     /*
55     * Start the python parser
56     */
57     status = Py_Main(argc, argv);
58    
59     /*
60     * Finalise MPI for a clean exit.
61     */
62     MPI_Finalize();
63    
64 ksteube 1312 Paso_MPIInfo_free( mpi_info );
65 bcumming 759 }
66     catch (std::runtime_error &e)
67     {
68     std::cerr << "EXCEPTION: " << e.what() << std::endl;
69     throw;
70     }
71     catch (char *e)
72     {
73     std::cerr << "EXCEPTION: " << e << std::endl;
74     throw;
75     }
76     catch (...)
77     {
78     std::cerr << "EXCEPTION: " << "UNKNOWN." << std::endl;
79     throw;
80     }
81    
82     return status;
83     }
84    
85     #else
86     int main( int argc, char **argv ) {
87     printf( "Esys must be compiled with PASO_MPI defined to make the MPI version available\n\n" );
88     return 0;
89     }
90     #endif

  ViewVC Help
Powered by ViewVC 1.1.26