144 int mpi_initialized = 0;
145 MPI_Initialized( &mpi_initialized );
146 if( !mpi_initialized )
148 MPI_Init( &argc, &argv );
153 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
154 MPI_Comm_size( MPI_COMM_WORLD, &nprocs );
166 auto moab = std::make_unique< Core >();
169 std::cerr <<
"Error: Failed to create MOAB instance" << std::endl;
170 MPI_Abort( MPI_COMM_WORLD, 1 );
174 auto pcomm = std::make_unique< ParallelComm >(
moab.get(), MPI_COMM_WORLD );
181 auto read_start = std::chrono::high_resolution_clock::now();
185 std::cout <<
"Reading mesh file..." << std::endl;
189 MB_CHK_SET_ERR(
moab->load_file( config.input_file.c_str(), &mesh_set, config.read_opts.c_str() ),
190 "Failed to read input file: " << config.input_file );
192 auto read_end = std::chrono::high_resolution_clock::now();
193 std::chrono::duration< double > read_elapsed = read_end - read_start;
197 std::cout <<
"Read completed in " << read_elapsed.count() <<
" seconds" << std::endl;
198 std::cout <<
"Writing mesh file..." << std::endl;
202 auto write_start = std::chrono::high_resolution_clock::now();
205 MB_CHK_SET_ERR(
moab->write_file( config.output_file.c_str(),
nullptr, config.write_opts.c_str(), &mesh_set,
207 "Failed to write output file: " << config.output_file );
209 auto write_end = std::chrono::high_resolution_clock::now();
210 std::chrono::duration< double > write_elapsed = write_end - write_start;
214 std::cout <<
"Write completed in " << write_elapsed.count() <<
" seconds" << std::endl;
215 std::cout <<
"\n=== Test completed successfully ===" << std::endl;
223 if( !mpi_initialized )
230 catch(
const std::exception& e )
232 std::cerr <<
"Error on rank " << rank <<
": " << e.what() << std::endl;
233 MPI_Abort( MPI_COMM_WORLD, 1 );
238 std::cerr <<
"Unknown error occurred on rank " << rank << std::endl;
239 MPI_Abort( MPI_COMM_WORLD, 1 );