/********** WX related headers ***********/ // For compilers that support precompilation, includes "wx.h". #include #ifndef WX_PRECOMP // Include your minimal set of headers here, or wx.h #include #endif /*********************************************************/ /************* MPI header ****************/ // may need to specify path to header file in MPI_path, // and need to set "MPI = false" in the Makefile #define MPI_quiver //need this to compile MPI #define MPI_path "/usr/local/mpich-1.2.5/include/mpi.h" #ifdef MPI_quiver #include MPI_path #else #include "pseudo_mpi.h" #endif /*********************************************************/ /************* other headers *************/ #include #include "frame.h" // header file for the frame /*********************************************************/ class MyApp: public wxApp { virtual bool OnInit(); }; bool MyApp::OnInit() { int size, rank; bool running=TRUE, compute=FALSE, output=FALSE; // Initialize MPI environment MPI::Init(argc,argv); //set up the communicator and find out which process I am rank = MPI::COMM_WORLD.Get_rank(); size = MPI::COMM_WORLD.Get_size(); //std::cout << "rank = " << rank << "\tsize = " << size << "\n"; // if I am process 0, make main window if (rank == 0) { qFrame *frame = new qFrame("Quiver",wxPoint(50,50),wxSize(450,340)); frame->Show(TRUE); SetTopWindow(frame); //return TRUE; // don't quit the process //std::cout << "Exiting master process " << rank << ".\n"; //MPI::Finalize(); //return TRUE; } // else I am a slave process else { std::cout << "Process " << rank << " running.\n"; while (running) { // rcv a bcast from master process with instruction if (compute) { // if compute, then compute } else if (output) { // if output, then output } // else exit else { std::cout << "Exiting process " << rank << ".\n"; MPI::Finalize(); running = FALSE; return 0; } } } }; IMPLEMENT_APP(MyApp);