00001 #ifndef __TSOPT_MPI_SEGYPP
00002 #define __TSOPT_MPI_SEGYPP
00003
00004 #include "segypp.hh"
00005 #include "mpiserialdc.hh"
00006 #include "mpiseriallap.hh"
00007
00008 namespace TSOpt {
00009
00010 using RVL::Space;
00011 using RVL::StdSpace;
00012 using RVL::MPISerialDC;
00013 using RVL::MPISerialDCF;
00014 using RVL::MPISerialLAP;
00015 using RVL::LinearAlgebraPackage;
00016 using RVL::DataContainerFactory;
00017 using RVL::ScalarFieldTraits;
00018
00019 class MPISEGYSpace: public StdSpace<float,float>,
00020 public ConstContainer<STRING_PAIR> {
00021
00022 private:
00023
00024 SEGYDCF f;
00025 MPISerialDCF mpif;
00026 MPISerialLAP<float> l;
00027 ostream & outfile;
00028
00029 protected:
00030
00031 Space<float> * clone() const { return new MPISEGYSpace(*this); }
00032
00033 public:
00034
00035 MPISEGYSpace(string hdr, string key
00036 #ifdef IWAVE_USE_MPI
00037 , MPI_Comm _comm=retrieveGlobalComm()
00038 #endif
00039 , ostream & _outfile = cerr)
00040 : StdSpace<float,float>(),
00041 ConstContainer<STRING_PAIR>(STRING_PAIR(key,hdr)),
00042 f(hdr,_outfile),
00043 mpif(f),
00044 l(ScalarFieldTraits<float>::One()
00045 , 0
00046 #ifdef IWAVE_USE_MPI
00047 , _comm
00048 #endif
00049 ),
00050 outfile(_outfile) {
00051 int rk = 0;
00052 #ifdef IWAVE_USE_MPI
00053 MPI_Comm_rank(_comm, &rk);
00054 #endif
00055 if (rk==0) l.setScale(f.getDt());
00056 }
00057
00058 MPISEGYSpace(MPISEGYSpace const & sp)
00059 : StdSpace<float,float>(),
00060 ConstContainer<STRING_PAIR>(sp.get()),
00061 f(sp.get().val,sp.outfile),
00062 mpif(f),
00063 l(sp.l),
00064 outfile(sp.outfile){ }
00065
00066 ~MPISEGYSpace() {}
00067
00068 LinearAlgebraPackage<float> const & getLAP() const { return l; }
00069
00070 DataContainerFactory const & getDCF() const { return mpif; }
00071
00073 float getDt() const {
00074 try {
00075 return f.getDt(); }
00076 catch (RVLException & e) {
00077 e<<"\ncalled from SEGYSpace::getDt\n";
00078 throw e;
00079 }
00080 }
00082 int getNt() const {
00083 try {
00084 return f.getNt(); }
00085 catch (RVLException & e) {
00086 e<<"\ncalled from SEGYSpace::getNt\n";
00087 throw e;
00088 }
00089 }
00090
00092 string getPrototypeFilename() const { return f.getFilename(); }
00093
00094 ostream & write(ostream & str) const {
00095 str<<"MPISEGYSpace: MPI-enabled StdSpace based on SEGYDC\n";
00096 str<<"trace data container class\n";
00097 str<<" - header file = "<<this->get().val<<"\n";
00098 str<<" - data type = "<<this->get().key<<"\n";
00099 return str;
00100 }
00101 };
00102 }
00103
00104 #endif