#include #include #include #include #include #include #include #include #include #include using namespace std; /* These two variables sets the command to launch in each sub-directory and the arguments required. The name of the root directory of the datasets is given as an argument when starting the MPIlauncher. const string commandToLaunch("/HA/sources/begou/SOURCES/MES-PROJETS/MPILAUNCHER/appli.exe"); const string("-l -info"); */ /* getListOfDir(string rep, vector &files) Gets the list of tjhe subdirectories in the directory rep and returns them in a vector array of strings. Directories ";" and ".." are removed from the vector array. */ int getListOfDir(string rep, vector &files) { DIR *dir; struct dirent *ent; int count; count=0; dir = opendir (rep.c_str()); if (dir != NULL) { /* search for the files within directory */ while ((ent = readdir (dir)) != NULL) if (ent->d_type == DT_DIR) { if (strcmp(ent->d_name,".") * strcmp(ent->d_name,"..")) { count++; files.push_back(string(ent->d_name)); } } closedir (dir); } else { cerr<<"Directory "< &files) Gets the list of commands in the ascii file fich. One command per line (no wrap) in this first version. */ int getListOfCommand(const string & fich, vector &commands) { int count; string line; count=0; commands.clear(); std::ifstream infile (fich.c_str(), std::ios_base::in); while (getline(infile, line, '\n')) { // remove all trailing blanks while(line.size() >0 && isspace(line[line.size() -1])) line.erase(line.size() -1); // no empty line if (line.size() > 0) { commands.push_back (line); count++; } } return count; } /* Main program */ int main(int argc, char **argv) { vector files = vector(); string rep; //root directory where to find subdirectories int rank, size, nbdir, stride; int nbcmd; /* These two variables sets the command to launch in each sub-directory and the arguments required. The name of the root directory of the datasets is given as an argument when starting the MPIlauncher. */ string commandToLaunch; string arguments; string commandfile; string finalCommand; //command to execute MPI_Init (&argc, &argv); /* starts MPI */ MPI_Comm_rank (MPI_COMM_WORLD, &rank); /* get current process id */ MPI_Comm_size (MPI_COMM_WORLD, &size); /* get number of processes */ if (argc<3){ cout<<"USAGE:"<0 && rank<=reste){ cerr<<"Process "<