#ifdef HAVE_CONFIG_H #include #endif #ifdef HAVE_MPI #include #include "comm/mpi/error_handler.hpp" #endif #include #include "comm/comm.hpp" #include "mg.hpp" using namespace VMG; int main(int argc, char* argv[]) { #ifdef HAVE_MPI int rank; MPI_Errhandler mpiErrorHandler; MPI_Init(&argc, &argv); MPI_Comm_create_errhandler(VMG::MPI::ConvertToException, &mpiErrorHandler); MPI_Comm_set_errhandler(MPI_COMM_WORLD, mpiErrorHandler); MPI_Comm_rank(MPI_COMM_WORLD, &rank); double start = MPI_Wtime(); #endif if (argc < 2) { #ifdef HAVE_MPI if (rank == 0) #endif std::printf("Wrong number of arguments specified.\nUsage: vmg_particles "); } MG::InitializeFromParticleConfigFile(argv[1]); if (!MG::IsInitialized()) { #ifdef HAVE_MPI std::printf("%d: VMG is not properly initialized. Please check your config file.\n", rank); MPI_Abort(MPI_COMM_WORLD, MPI_ERR_OTHER); #else std::printf("VMG is not properly initialized. Please check your config file.\n", rank); #endif return -1; } MG::Solve(); #ifdef HAVE_MPI double end = MPI_Wtime(); MG::GetComm()->PrintStringOnce("Running time: %e\n", end-start); #endif MG::Destroy(); #ifdef HAVE_MPI MPI_Finalize(); #endif return 0; }