8 const char usage[] =
"[-b|-d|-f] [-P <rank>] [-p <name>] [-R] [-g <level>] [-O <option>] <filename>";
14 std::cerr <<
"Usage: " << argv0 <<
" " <<
usage << std::endl;
18 void help(
const char* argv0 )
20 std::cout << argv0 <<
" " <<
usage << std::endl
21 <<
"-P <rank> Specified processor will wait for debugger to attach." << std::endl
22 <<
"-p <name> Tag identifying partition sets (default: \"" <<
DEFAULT_PARTITION_TAG <<
"\")" << std::endl
23 <<
"-a Assign partitions to processes by matching part number to rank" << std::endl
24 <<
"-R Do not resolve shared entities" << std::endl
25 <<
"-b Use broadcast & delete read method" << std::endl
26 <<
"-d Use read & delete method" << std::endl
27 <<
"-f Use true parallel read (default)" << std::endl
28 <<
"-g Set debug output level" << std::endl;
32 int main(
int argc,
char* argv[] )
34 MPI_Init( &argc, &argv );
36 const char BCAST_MODE[] =
"BCAST_DELETE";
37 const char DELETE_MODE[] =
"READ_DELETE";
38 const char PART_MODE[] =
"READ_PART";
39 const char* read_mode = PART_MODE;
41 bool assign_by_id =
false;
42 bool resolve_shared =
true;
45 const char* filename = 0;
46 std::ostringstream options;
50 MPI_Comm_rank( MPI_COMM_WORLD, &rank );
56 bool no_more_flags =
false;
57 for(
int i = 1; i < argc; ++i )
62 partition_tag_name = argv[i];
65 else if( expect_level == i )
68 debug_level = (int)strtol( argv[i], &endptr, 0 );
69 if( *endptr || endptr == argv[i] || debug_level < 0 )
71 std::cerr <<
"Expected positive integer value following '-g' flag" << std::endl;
76 else if( expect_opt == i )
78 options <<
";" << argv[i];
81 else if( expect_rank == i )
84 pause_rank = (int)strtol( argv[i], &endptr, 0 );
85 if( *endptr || endptr == argv[i] || pause_rank < 0 )
87 std::cerr <<
"Expected positive integer value following '-P' flag" << std::endl;
92 else if( argv[i][0] ==
'-' && !no_more_flags )
94 for(
int j = 1; argv[i][j]; ++j )
102 expect_rank = ++arg_pos;
105 expect_tag = ++arg_pos;
111 resolve_shared =
false;
114 read_mode = BCAST_MODE;
117 read_mode = DELETE_MODE;
120 read_mode = PART_MODE;
123 expect_level = ++arg_pos;
126 expect_opt = ++arg_pos;
132 std::cerr <<
"Unknown flag: -" << argv[i][j] << std::endl;
139 std::cerr <<
"Unexpected argument: \"" << argv[i] <<
"\"" << std::endl;
150 std::cerr <<
"Expected value following -p flag" << std::endl;
155 std::cerr <<
"Expected value following -g flag" << std::endl;
160 std::cerr <<
"Expected value following -O flag" << std::endl;
165 std::cerr <<
"Expected rank following -P flag" << std::endl;
170 std::cerr <<
"No file name specified" << std::endl;
174 options <<
";PARTITION=" << partition_tag_name <<
";PARALLEL=" << read_mode;
175 if( resolve_shared ) options <<
";PARALLEL_RESOLVE_SHARED_ENTS";
176 if( assign_by_id ) options <<
";PARTITION_BY_RANK";
177 if( debug_level ) options <<
";DEBUG_IO=" << debug_level;
182 if( pause_rank >= 0 )
184 if( pause_rank == rank )
186 std::cout <<
"Process " << rank <<
" with PID " << getpid() <<
" waiting for debugger" << std::endl
187 <<
"Set local variable 'do_wait' to zero to continue" << std::endl;
189 volatile int do_wait = 1;
195 MPI_Barrier( MPI_COMM_WORLD );
198 std::string opts = options.str();
199 if( rank == 0 ) std::cout <<
"Reading \"" << filename <<
"\" with options=\"" << opts <<
"\"." << std::endl;
201 double init_time = MPI_Wtime();
203 double fini_time = MPI_Wtime();
205 long send_data[2] = { (long)( 100 * ( fini_time - init_time ) ), rval };
207 MPI_Allreduce( send_data, recv_data, 2, MPI_LONG, MPI_MAX, MPI_COMM_WORLD );
208 double time = recv_data[0] / 100.0;
212 std::string estr =
mb.get_error_string( rval );
214 mb.get_last_error( msg );
215 std::cout <<
"Read failed for proccess " << rank <<
" with error code " << rval <<
" (" << estr <<
")"
217 if( !msg.empty() ) std::cerr <<
'"' << msg <<
'"' << std::endl;
222 if( recv_data[1] ==
moab::MB_SUCCESS ) std::cout <<
"Success!" << std::endl;
223 std::cout <<
"Read returned in " << time <<
" seconds" << std::endl;