Read mesh into MOAB and write some back
To run: mpiexec -np 4 ReadWriteTest [input] [output] -O [read_opts] -o [write_opts]
used for stress test of reader/writer report times to read and write
example ReadWriteTest ../MeshFiles/io/fv3x46x72.t.3.nc out.nc \ -O PARALLEL=READ_PART;PARTITION_METHOD=SQIJ;PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=T,U; \ -o PARALLEL=WRITE_PART;VARIABLE=T,U
#ifdef MOAB_HAVE_MPI
#endif
#include <iostream>
#include <ctime>
using namespace std;
int main(
int argc,
char** argv )
{
#ifdef MOAB_HAVE_MPI
string input_file, output_file, read_opts, write_opts;
MPI_Init( &argc, &argv );
if( argc < 3 )
{
#ifdef MOAB_HAVE_NETCDF
output_file = "ReadWriteTestOut.h5m";
read_opts = "PARALLEL=READ_PART;PARTITION_METHOD=SQIJ;PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=T,U";
write_opts = "PARALLEL=WRITE_PART";
#else
cout << "Usage: mpiexec -n $NP ReadWriteTest [input] [output] -O <read_opts> -o "
"<write_opts>\n";
return 0;
#endif
}
else
{
output_file = argv[2];
}
if( argc > 3 )
{
int index = 3;
while( index < argc )
{
if( !strcmp( argv[index], "-O" ) )
read_opts = argv[++index];
if( !strcmp( argv[index], "-o" ) ) write_opts = argv[++index];
index++;
}
}
Interface*
mb =
new( std::nothrow ) Core;
if( NULL ==
mb )
return 1;
ParallelComm* pcomm =
new ParallelComm(
mb, MPI_COMM_WORLD );
int nprocs = pcomm->proc_config().proc_size();
int rank = pcomm->proc_config().proc_rank();
clock_t tt = clock();
if( 0 == rank )
cout <<
"Reading file " <<
input_file <<
"\n with options: " << read_opts <<
"\n on " << nprocs
<< " processors\n";
if( 0 == rank )
{
cout << "Time: " << ( clock() - tt ) / (double)CLOCKS_PER_SEC << " seconds" << endl;
tt = clock();
}
rval =
mb->write_file( output_file.c_str(), 0, write_opts.c_str(), &set, 1 );
MB_CHK_ERR( rval );
if( 0 == rank )
{
cout << "Writing file " << output_file << "\n with options: " << write_opts << endl;
cout << "Time: " << ( clock() - tt ) / (double)CLOCKS_PER_SEC << " seconds" << endl;
tt = clock();
}
MPI_Finalize();
#else
std::cout << " compile MOAB with mpi for this example to work\n";
#endif
return 0;
}