#include "moab/Core.hpp" #include "moab/Interface.hpp" #include "moab/Range.hpp" #include "moab/ParallelComm.hpp" #include #define PRINT_LAST_ERROR \ if (MB_SUCCESS != result) {\ std::string tmp_str;\ mb->get_last_error(tmp_str);\ std::cout << "Failure; message:" << tmp_str << std::endl;\ delete mb;\ return result;\ } /* ========================================================== */ using namespace moab; using namespace std; int main(int argc, char **argv) { Interface* mb = new Core; ParallelComm* pcomm; string test_file_name; ErrorCode result = MB_SUCCESS; string options; if (argc > 1){ test_file_name = argv[1]; } options = "PARALLEL=READ_PART;PARTITION=PARALLEL_PARTITION;PARALLEL_RESOLVE_SHARED_ENTS"; // Get the ParallelComm instance pcomm = new ParallelComm(mb, MPI_COMM_WORLD); int nprocs = pcomm->proc_config().proc_size(); int rank = pcomm->proc_config().proc_rank(); //INPUT if (rank == 0) cout << "Reading file " << test_file_name << "\n with options: " << options << endl << " on " << nprocs << " processors\n"; result = mb->load_file(test_file_name.c_str(), 0, options.c_str()); PRINT_LAST_ERROR; //return 0; cout << "File loaded on processor " << rank << endl; // OUTPUT char buf [33]; std::string writeOpts = "PARALLEL=WRITE_PART"; std::string outFile = "out.h5m"; result = mb->write_file(outFile.c_str(), NULL, writeOpts.c_str()); PRINT_LAST_ERROR; if (rank == 0){ std::cout << "Wrote " << outFile << std::endl; } delete mb; return 0; }//END MAIN