Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
anonymous_namespace{ReadWriteTest.cpp} Namespace Reference

Classes

struct  Config
 

Functions

void print_usage (const char *program_name)
 
Config parse_arguments (int argc, char **argv)
 
void print_config (const Config &config, int rank, int nprocs)
 

Function Documentation

◆ parse_arguments()

Config anonymous_namespace{ReadWriteTest.cpp}::parse_arguments ( int  argc,
char **  argv 
)
Examples
ReadWriteTest.cpp.

Definition at line 76 of file ReadWriteTest.cpp.

77 {
78  Config config;
79 
80  // Set default values
81 #ifdef MOAB_HAVE_NETCDF
82  config.input_file = std::string( MESH_DIR ) + "/io/fv3x46x72.t.3.nc";
83  config.output_file = "ReadWriteTestOut.h5m";
84  config.read_opts = "PARALLEL=READ_PART;PARTITION_METHOD=SQIJ;PARALLEL_RESOLVE_SHARED_ENTS;VARIABLE=T,U";
85  config.write_opts = "PARALLEL=WRITE_PART";
86  config.use_defaults = true;
87 #else
88  if( argc < 3 )
89  {
90  print_usage( argv[0] );
91  std::exit( 1 );
92  }
93 #endif
94 
95  // Parse command line arguments if provided
96  if( argc >= 3 )
97  {
98  config.input_file = argv[1];
99  config.output_file = argv[2];
100  config.use_defaults = false;
101  }
102 
103  // Parse options
104  for( int i = 3; i < argc; ++i )
105  {
106  std::string arg = argv[i];
107  if( arg == "-O" && i + 1 < argc )
108  {
109  config.read_opts = argv[++i];
110  }
111  else if( arg == "-o" && i + 1 < argc )
112  {
113  config.write_opts = argv[++i];
114  }
115  else if( arg == "-h" || arg == "--help" )
116  {
117  print_usage( argv[0] );
118  std::exit( 0 );
119  }
120  }
121 
122  return config;
123 }

References anonymous_namespace{ReadWriteTest.cpp}::Config::input_file, MESH_DIR, anonymous_namespace{ReadWriteTest.cpp}::Config::output_file, print_usage(), anonymous_namespace{ReadWriteTest.cpp}::Config::read_opts, anonymous_namespace{ReadWriteTest.cpp}::Config::use_defaults, and anonymous_namespace{ReadWriteTest.cpp}::Config::write_opts.

Referenced by main().

◆ print_config()

void anonymous_namespace{ReadWriteTest.cpp}::print_config ( const Config config,
int  rank,
int  nprocs 
)
Examples
ReadWriteTest.cpp.

Definition at line 126 of file ReadWriteTest.cpp.

127 {
128  if( rank == 0 )
129  {
130  std::cout << "\n=== MOAB Parallel Read/Write Test ===\n"
131  << "Input file: " << config.input_file << "\n"
132  << "Output file: " << config.output_file << "\n"
133  << "Read options: " << ( config.read_opts.empty() ? "(default)" : config.read_opts ) << "\n"
134  << "Write options: " << ( config.write_opts.empty() ? "(default)" : config.write_opts ) << "\n"
135  << "Running on " << nprocs << " MPI processes\n"
136  << std::endl;
137  }
138 }

References anonymous_namespace{ReadWriteTest.cpp}::Config::input_file, anonymous_namespace{ReadWriteTest.cpp}::Config::output_file, anonymous_namespace{ReadWriteTest.cpp}::Config::read_opts, and anonymous_namespace{ReadWriteTest.cpp}::Config::write_opts.

Referenced by main().

◆ print_usage()

void anonymous_namespace{ReadWriteTest.cpp}::print_usage ( const char *  program_name)
Examples
ReadWriteTest.cpp.

Definition at line 63 of file ReadWriteTest.cpp.

64 {
65  std::cout << "Usage: mpiexec -np <num_procs> " << program_name << " [input_file] [output_file] [options]\n"
66  << "Options:\n"
67  << " -O <read_opts> Options for reading the input file\n"
68  << " -o <write_opts> Options for writing the output file\n"
69  << "\nExample:\n"
70  << " mpiexec -np 4 " << program_name << " input.nc output.h5m \\\n"
71  << " -O \"PARALLEL=READ_PART;PARTITION_METHOD=SQIJ\" \\n"
72  << " -o \"PARALLEL=WRITE_PART\"\n";
73 }

Referenced by parse_arguments().