cgma
ProcData.hpp
Go to the documentation of this file.
00001 #ifndef PROBDATA_HPP
00002 #define PROBDATA_HPP
00003 
00004 #ifdef USE_MPI
00005 #include "CGMmpi.h"
00006 #endif
00007 
00008 class ProcData 
00009 {
00010 public:
00011 
00012   ~ProcData();
00013     // destructor; calls MPI_Finalize
00014 
00015   static ProcData *instance();
00016     // singleton instance
00017   
00018   int initialize(int &argc, char **&argv);
00019     // initialize some communication parameters for this run
00020 
00021   int is_master() const {return myRank == masterRank;};
00022     // return whether this processor is the master or not
00023   
00024   int numProcs;
00025     // number of processors in this run
00026 
00027   int myRank;
00028     // rank of this processor
00029   
00030   int masterRank;
00031     // rank of the master process
00032 
00033 private:
00034 
00035   static ProcData *instance_;
00036     // static singleton instance
00037 
00038   static int isInitialized;
00039     // is this procdata initialized?
00040 
00041   ProcData() {};
00042     // private constructor, since this is a singleton
00043 
00044 };
00045 
00046 inline ProcData *ProcData::instance() 
00047 {
00048    if (instance_ == 0 ) {
00049      instance_ = new ProcData;
00050    }
00051    return instance_;
00052 }
00053 
00054 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines