59 "This program cannot be executed in a single working node");
64 addUsageLine(
"Run commands in a text file in a parallel environment");
65 addUsageLine(
"+You may use the tag MPI_BARRIER to separate execution blocks.");
66 addUsageLine(
"+You may use the tag MPI_NEWLINE to force a line break (this is useful for programs accepting parameters directly from stdin).");
67 addParamsLine(
"-i <commandFile> : File with commands in different lines");
74 std::cout <<
"Commands file: " << fn_commands << std::endl;
85 fh_in.open(fn_commands.c_str());
89 int number_of_node_waiting = 0;
93 MPI_Recv(0, 0, MPI_INT, MPI_ANY_SOURCE, 0,
94 MPI_COMM_WORLD, &status);
95 number_of_node_waiting++;
98 strcpy(szline, line.c_str());
100 std::string::size_type loc = line.find(
"MPI_BARRIER", 0);
101 if (loc != std::string::npos)
103 while (number_of_node_waiting < (node->
size - 1))
105 MPI_Recv(0, 0, MPI_INT, MPI_ANY_SOURCE, 0,
106 MPI_COMM_WORLD, &status);
107 number_of_node_waiting++;
109 while (number_of_node_waiting > 0)
111 MPI_Send(&szline, 1, MPI_CHAR, number_of_node_waiting,
113 number_of_node_waiting--;
119 MPI_Send(&szline,
MAX_LINE, MPI_CHAR, status.MPI_SOURCE,
121 number_of_node_waiting--;
125 for (
size_t i = 1;
i < node->
size;
i++)
126 MPI_Send(0, 0, MPI_INT,
i,
TAG_STOP, MPI_COMM_WORLD);
133 MPI_Send(0, 0, MPI_INT, 0, 0, MPI_COMM_WORLD);
135 MPI_Probe(0, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
138 else if (status.MPI_TAG ==
TAG_WAIT)
140 MPI_Recv(&szline, 1, MPI_CHAR, 0,
TAG_WAIT, MPI_COMM_WORLD, &status);
143 else if (status.MPI_TAG ==
TAG_WORK)
145 MPI_Recv(&szline,
MAX_LINE, MPI_CHAR, 0,
TAG_WORK, MPI_COMM_WORLD, &status);
151 if (system(szline)==-1)
156 std::cerr <<
"WRONG TAG RECEIVED" << std::endl;
Just to locate unclassified errors.
#define REPORT_ERROR(nerr, ErrormMsg)
int argc
Original command line arguments.
const char * getParam(const char *param, int arg=0)
Incorrect argument received.
String findAndReplace(const String &tInput, const String &tFind, const String &tReplace)
int verbose
Verbosity level.
ProgMPIRun(int argc, char **argv)
void addUsageLine(const char *line, bool verbatim=false)
void addParamsLine(const String &line)