Newsgroups: comp.parallel.mpi
From: george@holmes.cs.nps.navy.mil (Robert George)
Subject: Re: MPI_Finalize necessary ?
Organization: Naval Postgraduate School, Monterey
Date: Fri, 8 Sep 1995 22:20:26 GMT
Message-ID: <DELy22.Exz@taurus.cs.nps.navy.mil>

In article <dbc.810575495@euclid>, dbc@ecs.soton.ac.uk (Bryan Carpenter) writes:
|> In <FURNISH.95Sep5132513@dino.ph.utexas.edu> furnish@dino.ph.utexas.edu (Geoffrey Furnish) writes:
|> >[...]  For example, in C++, you could easily imagine
|> >an MPI parallel framework class along the lines of:
|> 
|> >class MPI_App {
|> >...
|> >public:
|> >    MPI_App(...) {
|> >	MPI_Init(...);
|> >    }
|> >    ~MPI_App() {
|> >	MPI_Finalize();
|> >    }
|> >};
|> >
|> Oh good.  This gives me another opportunity to whinge about my least
|> favourite feature in MPI.
|> 
|> Personally I would love to do something along the lines you describe.
|> *But* `MPI_Init' takes `argc' and `argv' as arguments...  (Arghh...)
|> So the the constructor for `MPI_App' has to take these as arguments.
|> So the object of type `MPI_App' would have to be declared in the main
|> program (and passed about to other routines if they had to apply
|> methods to it).

Bryan,
     Why don't you just do something like:

class MPI_App {
// Set as protected if derived classes need the command line
    int  argc;
    char *argv[];
public:
    MPI_App(int num_args, char *arg_vec[]) : argc(num_arg), argv(arg_vec)
    {
	MPI_Init(&argc, &argv);
    }
    ~MPI_App()
    {
	MPI_Finalize();
    }
};

...and have your user application inherit from MPI_App?

Granted, you will have to instantiate MPI_App in main(), but so what?

Robert

___________________________________________________________________________
Robert George      Computer Engineer     (408) 656-3316 Fax: (408) 656-2814
Army Research Laboratory/AMSRL-SS-IC/2800 Powder Mill Rd/Adelphi, MD 20783
            URL: http://cs.nps.navy.mil/people/phd/george
"That is really incredible. That is truly incredible.  That is so incredibly
 incredible that I think I'd like to steal it.    --Zaphod Beeblebrox" 

